i18next-cli 1.25.0 → 1.25.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/cjs/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=require("commander"),o=require("chokidar"),t=require("glob"),n=require("minimatch"),i=require("chalk"),r=require("./config.js"),a=require("./heuristic-config.js"),c=require("./extractor/core/extractor.js");require("node:path"),require("node:fs/promises"),require("jiti");var s=require("./types-generator.js"),l=require("./syncer.js"),u=require("./migrator.js"),d=require("./init.js"),g=require("./linter.js"),f=require("./status.js"),p=require("./locize.js"),m=require("./rename-key.js");const y=new e.Command;y.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.25.0"),y.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),y.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async e=>{try{const t=y.opts().config,i=await r.ensureConfig(t),a=async()=>{const o=await c.runExtractor(i,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:!!e.syncPrimary});return e.ci&&!o?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&o&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),o};if(await a(),e.watch){console.log("\nWatching for changes...");const e=await x(i.extract.input),t=h(i.extract.ignore),r=w(i.extract.output),c=[...t,...r].filter(Boolean),s=e.filter(e=>!c.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}catch(e){console.error("Error running extractor:",e),process.exit(1)}}),y.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(e,o)=>{const t=y.opts().config;let n=await r.loadConfig(t);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await a.detectConfig();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=e}await f.runStatus(n,{detail:e,namespace:o.namespace})}),y.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async e=>{const t=y.opts().config,i=await r.ensureConfig(t),a=()=>s.runTypesGenerator(i);if(await a(),e.watch){console.log("\nWatching for changes...");const e=await x(i.types?.input||[]),t=[...h(i.extract?.ignore)].filter(Boolean),r=e.filter(e=>!t.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(r,{persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}),y.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=y.opts().config,o=await r.ensureConfig(e);await l.runSyncer(o)}),y.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await u.runMigrator(e)}),y.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(d.runInit),y.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async e=>{const t=y.opts().config,c=async()=>{let e=await r.loadConfig(t);if(!e){console.log(i.blue("No config file found. Attempting to detect project structure..."));const o=await a.detectConfig();o||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),e=o}await g.runLinterCli(e)};if(await c(),e.watch){console.log("\nWatching for changes...");const e=await r.loadConfig(t);if(e?.extract?.input){const t=await x(e.extract.input),i=[...h(e.extract.ignore),...w(e.extract.output)].filter(Boolean),r=t.filter(e=>!i.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),c()})}}}),y.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async e=>{const o=y.opts().config,t=await r.ensureConfig(o);await p.runLocizeSync(t,e)}),y.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const o=y.opts().config,t=await r.ensureConfig(o);await p.runLocizeDownload(t,e)}),y.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const o=y.opts().config,t=await r.ensureConfig(o);await p.runLocizeMigrate(t,e)}),y.command("rename-key <oldKey> <newKey>").description("Rename a translation key across all source files and translation files.").option("--dry-run","Preview changes without modifying files").action(async(e,o,t)=>{try{const n=y.opts().config,a=await r.ensureConfig(n),c=await m.runRenameKey(a,e,o,t);c.success||(c.conflicts&&(console.error(i.red("\n❌ Conflicts detected:")),c.conflicts.forEach(e=>console.error(` - ${e}`))),c.error&&console.error(i.red(`\n❌ ${c.error}`)),process.exit(1));0===c.sourceFiles.reduce((e,o)=>e+o.changes,0)&&console.log(i.yellow(`\n⚠️ No usages found for "${e}"`))}catch(e){console.error(i.red("Error renaming key:"),e),process.exit(1)}}),y.parse(process.argv);const h=e=>Array.isArray(e)?e:e?[e]:[],w=e=>e&&"string"==typeof e?[e.replace(/\{\{[^}]+\}\}/g,"*")]:[],x=async(e=[])=>{const o=h(e),n=await Promise.all(o.map(e=>t.glob(e||"",{nodir:!0})));return Array.from(new Set(n.flat()))};exports.program=y;
2
+ "use strict";var e=require("commander"),o=require("chokidar"),t=require("glob"),n=require("minimatch"),i=require("chalk"),r=require("./config.js"),a=require("./heuristic-config.js"),c=require("./extractor/core/extractor.js");require("node:path"),require("node:fs/promises"),require("jiti");var s=require("./types-generator.js"),l=require("./syncer.js"),u=require("./migrator.js"),d=require("./init.js"),g=require("./linter.js"),f=require("./status.js"),p=require("./locize.js"),m=require("./rename-key.js");const y=new e.Command;y.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.25.1"),y.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),y.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async e=>{try{const t=y.opts().config,i=await r.ensureConfig(t),a=async()=>{const o=await c.runExtractor(i,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:!!e.syncPrimary});return e.ci&&!o?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&o&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),o};if(await a(),e.watch){console.log("\nWatching for changes...");const e=await x(i.extract.input),t=h(i.extract.ignore),r=w(i.extract.output),c=[...t,...r].filter(Boolean),s=e.filter(e=>!c.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}catch(e){console.error("Error running extractor:",e),process.exit(1)}}),y.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(e,o)=>{const t=y.opts().config;let n=await r.loadConfig(t);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await a.detectConfig();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=e}await f.runStatus(n,{detail:e,namespace:o.namespace})}),y.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async e=>{const t=y.opts().config,i=await r.ensureConfig(t),a=()=>s.runTypesGenerator(i);if(await a(),e.watch){console.log("\nWatching for changes...");const e=await x(i.types?.input||[]),t=[...h(i.extract?.ignore)].filter(Boolean),r=e.filter(e=>!t.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(r,{persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}),y.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=y.opts().config,o=await r.ensureConfig(e);await l.runSyncer(o)}),y.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await u.runMigrator(e)}),y.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(d.runInit),y.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async e=>{const t=y.opts().config,c=async()=>{let e=await r.loadConfig(t);if(!e){console.log(i.blue("No config file found. Attempting to detect project structure..."));const o=await a.detectConfig();o||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),e=o}await g.runLinterCli(e)};if(await c(),e.watch){console.log("\nWatching for changes...");const e=await r.loadConfig(t);if(e?.extract?.input){const t=await x(e.extract.input),i=[...h(e.extract.ignore),...w(e.extract.output)].filter(Boolean),r=t.filter(e=>!i.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),c()})}}}),y.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async e=>{const o=y.opts().config,t=await r.ensureConfig(o);await p.runLocizeSync(t,e)}),y.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const o=y.opts().config,t=await r.ensureConfig(o);await p.runLocizeDownload(t,e)}),y.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const o=y.opts().config,t=await r.ensureConfig(o);await p.runLocizeMigrate(t,e)}),y.command("rename-key <oldKey> <newKey>").description("Rename a translation key across all source files and translation files.").option("--dry-run","Preview changes without modifying files").action(async(e,o,t)=>{try{const n=y.opts().config,a=await r.ensureConfig(n),c=await m.runRenameKey(a,e,o,t);c.success||(c.conflicts&&(console.error(i.red("\n❌ Conflicts detected:")),c.conflicts.forEach(e=>console.error(` - ${e}`))),c.error&&console.error(i.red(`\n❌ ${c.error}`)),process.exit(1));0===c.sourceFiles.reduce((e,o)=>e+o.changes,0)&&console.log(i.yellow(`\n⚠️ No usages found for "${e}"`))}catch(e){console.error(i.red("Error renaming key:"),e),process.exit(1)}}),y.parse(process.argv);const h=e=>Array.isArray(e)?e:e?[e]:[],w=e=>e&&"string"==typeof e?[e.replace(/\{\{[^}]+\}\}/g,"*")]:[],x=async(e=[])=>{const o=h(e),n=await Promise.all(o.map(e=>t.glob(e||"",{nodir:!0})));return Array.from(new Set(n.flat()))};exports.program=y;
@@ -1 +1 @@
1
- "use strict";var e=require("glob"),t=require("node:fs/promises"),r=require("@swc/core"),n=require("node:path"),s=require("node:events"),o=require("chalk"),i=require("ora");class a extends s.EventEmitter{config;constructor(e){super({captureRejections:!0}),this.config=e}wrapError(e){const t="Linter failed to run: ";if(e instanceof Error){if(e.message.startsWith(t))return e;const r=new Error(`${t}${e.message}`);return r.stack=e.stack,r}return new Error(`${t}${String(e)}`)}async run(){const{config:s}=this;try{this.emit("progress",{message:"Finding source files to analyze..."});const o=["node_modules/**"],i=Array.isArray(s.extract.ignore)?s.extract.ignore:s.extract.ignore?[s.extract.ignore]:[],a=await e.glob(s.extract.input,{ignore:[...o,...i]});this.emit("progress",{message:`Analyzing ${a.length} source files...`});let c=0;const u=new Map;for(const e of a){const o=await t.readFile(e,"utf-8"),i=n.extname(e).toLowerCase(),a=".ts"===i||".tsx"===i||".mts"===i||".cts"===i,p=".tsx"===i,f=".jsx"===i;let g;try{g=await r.parse(o,{syntax:a?"typescript":"ecmascript",tsx:p,jsx:f,decorators:!0})}catch(t){if(".ts"!==i||p){const e=this.wrapError(t);this.emit("error",e);continue}try{g=await r.parse(o,{syntax:"typescript",tsx:!0,decorators:!0}),this.emit("progress",{message:`Parsed ${e} using TSX fallback`})}catch(e){const t=this.wrapError(e);this.emit("error",t);continue}}const m=l(g,o,s);m.length>0&&(c+=m.length,u.set(e,m))}const p={success:0===c,message:c>0?`Linter found ${c} potential issues.`:"No issues found.",files:Object.fromEntries(u.entries())};return this.emit("done",p),p}catch(e){const t=this.wrapError(e);throw this.emit("error",t),t}}}const c=e=>/^(https|http|\/\/|^\/)/.test(e);function l(e,t,r){const n=[],s=[],o=e=>t.substring(0,e).split("\n").length,i=(r.extract.transComponents||["Trans"]).map(e=>e.toLowerCase()),a=["className","key","id","style","href","i18nKey","defaults","type","target"].map(e=>e.toLowerCase()),l=(r?.lint?.ignoredTags||r.extract.ignoredTags||[]).map(e=>e.toLowerCase()),u=new Set([...i,...["script","style","code"].map(e=>e.toLowerCase()),...l]),p=(r?.lint?.ignoredAttributes||r.extract.ignoredAttributes||[]).map(e=>e.toLowerCase()),f=new Set([...a,...p]),g=(r?.lint?.acceptedTags&&r.lint.acceptedTags.length>0?r.lint.acceptedTags:r?.extract?.acceptedTags&&r.extract.acceptedTags.length>0?r.extract.acceptedTags:null)?.map(e=>e.toLowerCase())??null,m=(r?.lint?.acceptedAttributes&&r.lint.acceptedAttributes.length>0?r.lint.acceptedAttributes:r?.extract?.acceptedAttributes&&r.extract.acceptedAttributes.length>0?r.extract.acceptedAttributes:null)?.map(e=>e.toLowerCase())??null,y=g?new Set(g):null,d=m?new Set(m):null,h=e=>{if(!e)return null;const t=e.name??e.opening?.name??e.opening?.name;if(!t)return e.opening?.name?h({name:e.opening.name}):null;const r=e=>{if(!e)return null;if("JSXIdentifier"===e.type&&(e.name||e.value))return e.name??e.value;if("Identifier"===e.type&&(e.name||e.value))return e.name??e.value;if("JSXMemberExpression"===e.type){const t=r(e.object),n=r(e.property);return t&&n?`${t}.${n}`:n??t}return e.name??e.value??e.property?.name??e.property?.value??null},n=r(t);return n?String(n):null},x=e=>{if(!e)return null;if("string"==typeof e)return e;if("JSXIdentifier"===e.type||"Identifier"===e.type){const t=e.name??e.value??e.raw??null;return t?String(t):null}if("JSXNamespacedName"===e.type)return x(e.name)??x(e.namespace);if("JSXMemberExpression"===e.type){const t=x(e.object),r=x(e.property);return t&&r?`${t}.${r}`:r??t}if(e.name||e.value||e.property)return e.name??e.value??e.property?.name??e.property?.value??null;try{const t=JSON.stringify(e),r=/"?(?:name|value)"?\s*:\s*"?([a-zA-Z0-9_\-:.$]+)"?/.exec(t);return r?r[1]:null}catch{return null}},w=e=>{for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=h(r);if(!e)continue;if(u.has(String(e).toLowerCase()))return!0}}if(y){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=h(r);if(!e)continue;return!y.has(String(e).toLowerCase())}}return!0}return!1},S=(e,t)=>{if(!e||"object"!=typeof e)return;const r=[...t,e];if("JSXText"===e.type)if(d&&!y);else{if(!w(r)){const t=e.value.trim();t&&t.length>1&&"..."!==t&&!c(t)&&isNaN(Number(t))&&!t.startsWith("{{")&&s.push(e)}}if("StringLiteral"===e.type){const t=r[r.length-2],n=w(r);if("JSXAttribute"===t?.type&&!n){const n=x(t.name),o=n?String(n).toLowerCase():null,i=r.slice(0,-2).reverse().find(e=>e&&"object"==typeof e&&("JSXElement"===e.type||"JSXOpeningElement"===e.type||"JSXSelfClosingElement"===e.type));if(y&&i){const e=h(i);if(!e||!y.has(String(e).toLowerCase()))return}else if(y&&!i)return;if(d?null!=o&&d.has(o):null!=o&&!f.has(o)){const t=e.value.trim();t&&"..."!==t&&!c(t)&&isNaN(Number(t))&&s.push(e)}}}for(const t of Object.keys(e)){if("span"===t)continue;const n=e[t];Array.isArray(n)?n.forEach(e=>S(e,r)):n&&"object"==typeof n&&S(n,r)}};S(e,[]);let b=0;for(const e of s){const r=e.raw??e.value,s=t.indexOf(r,b);s>-1&&(n.push({text:e.value.trim(),line:o(s)}),b=s+r.length)}return n}exports.Linter=a,exports.runLinter=async function(e){return new a(e).run()},exports.runLinterCli=async function(e){const t=new a(e),r=i().start();t.on("progress",e=>{r.text=e.message});try{const{success:e,message:n,files:s}=await t.run();if(e)r.succeed(o.green.bold(n));else{r.fail(o.red.bold(n));for(const[e,t]of Object.entries(s))console.log(o.yellow(`\n${e}`)),t.forEach(({text:e,line:t})=>{console.log(` ${o.gray(`${t}:`)} ${o.red("Error:")} Found hardcoded string: "${e}"`)});process.exit(1)}}catch(e){const n=t.wrapError(e);r.fail(n.message),console.error(n),process.exit(1)}};
1
+ "use strict";var e=require("glob"),t=require("node:fs/promises"),r=require("@swc/core"),n=require("node:path"),s=require("node:events"),a=require("chalk"),o=require("ora");const i=["a","abbr","address","article","aside","bdi","bdo","blockquote","button","caption","cite","code","data","dd","del","details","dfn","dialog","div","dt","em","figcaption","footer","h1","h2","h3","h4","h5","h6","header","img","ins","kbd","label","legend","li","main","mark","nav","option","output","p","pre","q","s","samp","section","small","span","strong","sub","summary","sup","td","textarea","th","time","title","var"].map(e=>e.toLowerCase()),l=["abbr","accesskey","alt","aria-description","aria-label","aria-placeholder","aria-roledescription","aria-valuetext","content","label","placeholder","summary","title"].map(e=>e.toLowerCase()),c=["className","key","id","style","href","i18nKey","defaults","type","target"].map(e=>e.toLowerCase()),u=["script","style","code"];class p extends s.EventEmitter{config;constructor(e){super({captureRejections:!0}),this.config=e}wrapError(e){const t="Linter failed to run: ";if(e instanceof Error){if(e.message.startsWith(t))return e;const r=new Error(`${t}${e.message}`);return r.stack=e.stack,r}return new Error(`${t}${String(e)}`)}async run(){const{config:s}=this;try{this.emit("progress",{message:"Finding source files to analyze..."});const a=["node_modules/**"],o=Array.isArray(s.extract.ignore)?s.extract.ignore:s.extract.ignore?[s.extract.ignore]:[],i=await e.glob(s.extract.input,{ignore:[...a,...o]});this.emit("progress",{message:`Analyzing ${i.length} source files...`});let l=0;const c=new Map;for(const e of i){const a=await t.readFile(e,"utf-8"),o=n.extname(e).toLowerCase(),i=".ts"===o||".tsx"===o||".mts"===o||".cts"===o,u=".tsx"===o,p=".jsx"===o;let f;try{f=await r.parse(a,{syntax:i?"typescript":"ecmascript",tsx:u,jsx:p,decorators:!0})}catch(t){if(".ts"!==o||u){const e=this.wrapError(t);this.emit("error",e);continue}try{f=await r.parse(a,{syntax:"typescript",tsx:!0,decorators:!0}),this.emit("progress",{message:`Parsed ${e} using TSX fallback`})}catch(e){const t=this.wrapError(e);this.emit("error",t);continue}}const g=m(f,a,s);g.length>0&&(l+=g.length,c.set(e,g))}const u={success:0===l,message:l>0?`Linter found ${l} potential issues.`:"No issues found.",files:Object.fromEntries(c.entries())};return this.emit("done",u),u}catch(e){const t=this.wrapError(e);throw this.emit("error",t),t}}}const f=e=>/^(https|http|\/\/|^\/)/.test(e);function m(e,t,r){const n=[],s=[],a=e=>t.substring(0,e).split("\n").length,o=(r.extract.transComponents||["Trans"]).map(e=>e.toLowerCase()),p=(r?.lint?.ignoredTags||r.extract.ignoredTags||[]).map(e=>e.toLowerCase()),m=new Set([...o,...u.map(e=>e.toLowerCase()),...p]),g=(r?.lint?.ignoredAttributes||r.extract.ignoredAttributes||[]).map(e=>e.toLowerCase()),d=new Set([...c,...g]),y=r?.lint?.acceptedTags?r.lint.acceptedTags:null,h=r?.extract?.acceptedTags?r.extract.acceptedTags:null,b=(y??h??i)?.map(e=>e.toLowerCase())??null,w=r?.lint?.acceptedAttributes?r.lint.acceptedAttributes:null,x=r?.extract?.acceptedAttributes?r.extract.acceptedAttributes:null,S=(w??x??l)?.map(e=>e.toLowerCase())??null,E=b&&b.length>0?new Set(b):null,v=S&&S.length>0?new Set(S):null,L=e=>{if(!e)return null;const t=e.name??e.opening?.name??e.opening?.name;if(!t)return e.opening?.name?L({name:e.opening.name}):null;const r=e=>{if(!e)return null;if("JSXIdentifier"===e.type&&(e.name||e.value))return e.name??e.value;if("Identifier"===e.type&&(e.name||e.value))return e.name??e.value;if("JSXMemberExpression"===e.type){const t=r(e.object),n=r(e.property);return t&&n?`${t}.${n}`:n??t}return e.name??e.value??e.property?.name??e.property?.value??null},n=r(t);return n?String(n):null},C=e=>{if(!e)return null;if("string"==typeof e)return e;if("JSXIdentifier"===e.type||"Identifier"===e.type){const t=e.name??e.value??e.raw??null;return t?String(t):null}if("JSXNamespacedName"===e.type)return C(e.name)??C(e.namespace);if("JSXMemberExpression"===e.type){const t=C(e.object),r=C(e.property);return t&&r?`${t}.${r}`:r??t}if(e.name||e.value||e.property)return e.name??e.value??e.property?.name??e.property?.value??null;try{const t=JSON.stringify(e),r=/"?(?:name|value)"?\s*:\s*"?([a-zA-Z0-9_\-:.$]+)"?/.exec(t);return r?r[1]:null}catch{return null}},J=e=>{for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=L(r);if(!e)continue;if(m.has(String(e).toLowerCase()))return!0}}if(E){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=L(r);if(!e)continue;return!E.has(String(e).toLowerCase())}}return!0}return!1},X=(e,t)=>{if(!e||"object"!=typeof e)return;const r=[...t,e];if("JSXText"===e.type)if(v&&!E);else{if(!J(r)){const t=e.value.trim();t&&t.length>1&&"..."!==t&&!f(t)&&isNaN(Number(t))&&!t.startsWith("{{")&&s.push(e)}}if("StringLiteral"===e.type){const t=r[r.length-2],n=J(r);if("JSXAttribute"===t?.type&&!n){const n=C(t.name),a=n?String(n).toLowerCase():null,o=r.slice(0,-2).reverse().find(e=>e&&"object"==typeof e&&("JSXElement"===e.type||"JSXOpeningElement"===e.type||"JSXSelfClosingElement"===e.type));if(E&&o){const e=L(o);if(!e||!E.has(String(e).toLowerCase()))return}else if(E&&!o)return;if(v?null!=a&&v.has(a):null!=a&&!d.has(a)){const t=e.value.trim();t&&"..."!==t&&!f(t)&&isNaN(Number(t))&&s.push(e)}}}for(const t of Object.keys(e)){if("span"===t)continue;const n=e[t];Array.isArray(n)?n.forEach(e=>X(e,r)):n&&"object"==typeof n&&X(n,r)}};X(e,[]);let $=0;for(const e of s){const r=e.raw??e.value,s=t.indexOf(r,$);s>-1&&(n.push({text:e.value.trim(),line:a(s)}),$=s+r.length)}return n}exports.Linter=p,exports.runLinter=async function(e){return new p(e).run()},exports.runLinterCli=async function(e){const t=new p(e),r=o().start();t.on("progress",e=>{r.text=e.message});try{const{success:e,message:n,files:s}=await t.run();if(e)r.succeed(a.green.bold(n));else{r.fail(a.red.bold(n));for(const[e,t]of Object.entries(s))console.log(a.yellow(`\n${e}`)),t.forEach(({text:e,line:t})=>{console.log(` ${a.gray(`${t}:`)} ${a.red("Error:")} Found hardcoded string: "${e}"`)});process.exit(1)}}catch(e){const n=t.wrapError(e);r.fail(n.message),console.error(n),process.exit(1)}};
package/dist/esm/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Command as o}from"commander";import e from"chokidar";import{glob as t}from"glob";import{minimatch as n}from"minimatch";import i from"chalk";import{ensureConfig as r,loadConfig as a}from"./config.js";import{detectConfig as c}from"./heuristic-config.js";import{runExtractor as s}from"./extractor/core/extractor.js";import"node:path";import"node:fs/promises";import"jiti";import{runTypesGenerator as l}from"./types-generator.js";import{runSyncer as p}from"./syncer.js";import{runMigrator as f}from"./migrator.js";import{runInit as m}from"./init.js";import{runLinterCli as d}from"./linter.js";import{runStatus as g}from"./status.js";import{runLocizeSync as u,runLocizeDownload as y,runLocizeMigrate as h}from"./locize.js";import{runRenameKey as w}from"./rename-key.js";const x=new o;x.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.25.0"),x.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),x.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async o=>{try{const t=x.opts().config,i=await r(t),a=async()=>{const e=await s(i,{isWatchMode:!!o.watch,isDryRun:!!o.dryRun,syncPrimaryWithDefaults:!!o.syncPrimary});return o.ci&&!e?(console.log("✅ No files were updated."),process.exit(0)):o.ci&&e&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),e};if(await a(),o.watch){console.log("\nWatching for changes...");const o=await z(i.extract.input),t=j(i.extract.ignore),r=k(i.extract.output),c=[...t,...r].filter(Boolean),s=o.filter(o=>!c.some(e=>n(o,e,{dot:!0})));e.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),a()})}}catch(o){console.error("Error running extractor:",o),process.exit(1)}}),x.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(o,e)=>{const t=x.opts().config;let n=await a(t);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const o=await c();o||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=o}await g(n,{detail:o,namespace:e.namespace})}),x.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async o=>{const t=x.opts().config,i=await r(t),a=()=>l(i);if(await a(),o.watch){console.log("\nWatching for changes...");const o=await z(i.types?.input||[]),t=[...j(i.extract?.ignore)].filter(Boolean),r=o.filter(o=>!t.some(e=>n(o,e,{dot:!0})));e.watch(r,{persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),a()})}}),x.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const o=x.opts().config,e=await r(o);await p(e)}),x.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async o=>{await f(o)}),x.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(m),x.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async o=>{const t=x.opts().config,r=async()=>{let o=await a(t);if(!o){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await c();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),o=e}await d(o)};if(await r(),o.watch){console.log("\nWatching for changes...");const o=await a(t);if(o?.extract?.input){const t=await z(o.extract.input),i=[...j(o.extract.ignore),...k(o.extract.output)].filter(Boolean),a=t.filter(o=>!i.some(e=>n(o,e,{dot:!0})));e.watch(a,{ignored:/node_modules/,persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),r()})}}}),x.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async o=>{const e=x.opts().config,t=await r(e);await u(t,o)}),x.command("locize-download").description("Download all translations from your locize project.").action(async o=>{const e=x.opts().config,t=await r(e);await y(t,o)}),x.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async o=>{const e=x.opts().config,t=await r(e);await h(t,o)}),x.command("rename-key <oldKey> <newKey>").description("Rename a translation key across all source files and translation files.").option("--dry-run","Preview changes without modifying files").action(async(o,e,t)=>{try{const n=x.opts().config,a=await r(n),c=await w(a,o,e,t);c.success||(c.conflicts&&(console.error(i.red("\n❌ Conflicts detected:")),c.conflicts.forEach(o=>console.error(` - ${o}`))),c.error&&console.error(i.red(`\n❌ ${c.error}`)),process.exit(1));0===c.sourceFiles.reduce((o,e)=>o+e.changes,0)&&console.log(i.yellow(`\n⚠️ No usages found for "${o}"`))}catch(o){console.error(i.red("Error renaming key:"),o),process.exit(1)}}),x.parse(process.argv);const j=o=>Array.isArray(o)?o:o?[o]:[],k=o=>o&&"string"==typeof o?[o.replace(/\{\{[^}]+\}\}/g,"*")]:[],z=async(o=[])=>{const e=j(o),n=await Promise.all(e.map(o=>t(o||"",{nodir:!0})));return Array.from(new Set(n.flat()))};export{x as program};
2
+ import{Command as o}from"commander";import e from"chokidar";import{glob as t}from"glob";import{minimatch as n}from"minimatch";import i from"chalk";import{ensureConfig as r,loadConfig as a}from"./config.js";import{detectConfig as c}from"./heuristic-config.js";import{runExtractor as s}from"./extractor/core/extractor.js";import"node:path";import"node:fs/promises";import"jiti";import{runTypesGenerator as l}from"./types-generator.js";import{runSyncer as p}from"./syncer.js";import{runMigrator as f}from"./migrator.js";import{runInit as m}from"./init.js";import{runLinterCli as d}from"./linter.js";import{runStatus as g}from"./status.js";import{runLocizeSync as u,runLocizeDownload as y,runLocizeMigrate as h}from"./locize.js";import{runRenameKey as w}from"./rename-key.js";const x=new o;x.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.25.1"),x.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),x.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async o=>{try{const t=x.opts().config,i=await r(t),a=async()=>{const e=await s(i,{isWatchMode:!!o.watch,isDryRun:!!o.dryRun,syncPrimaryWithDefaults:!!o.syncPrimary});return o.ci&&!e?(console.log("✅ No files were updated."),process.exit(0)):o.ci&&e&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),e};if(await a(),o.watch){console.log("\nWatching for changes...");const o=await z(i.extract.input),t=j(i.extract.ignore),r=k(i.extract.output),c=[...t,...r].filter(Boolean),s=o.filter(o=>!c.some(e=>n(o,e,{dot:!0})));e.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),a()})}}catch(o){console.error("Error running extractor:",o),process.exit(1)}}),x.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(o,e)=>{const t=x.opts().config;let n=await a(t);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const o=await c();o||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=o}await g(n,{detail:o,namespace:e.namespace})}),x.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async o=>{const t=x.opts().config,i=await r(t),a=()=>l(i);if(await a(),o.watch){console.log("\nWatching for changes...");const o=await z(i.types?.input||[]),t=[...j(i.extract?.ignore)].filter(Boolean),r=o.filter(o=>!t.some(e=>n(o,e,{dot:!0})));e.watch(r,{persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),a()})}}),x.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const o=x.opts().config,e=await r(o);await p(e)}),x.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async o=>{await f(o)}),x.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(m),x.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async o=>{const t=x.opts().config,r=async()=>{let o=await a(t);if(!o){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await c();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),o=e}await d(o)};if(await r(),o.watch){console.log("\nWatching for changes...");const o=await a(t);if(o?.extract?.input){const t=await z(o.extract.input),i=[...j(o.extract.ignore),...k(o.extract.output)].filter(Boolean),a=t.filter(o=>!i.some(e=>n(o,e,{dot:!0})));e.watch(a,{ignored:/node_modules/,persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),r()})}}}),x.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async o=>{const e=x.opts().config,t=await r(e);await u(t,o)}),x.command("locize-download").description("Download all translations from your locize project.").action(async o=>{const e=x.opts().config,t=await r(e);await y(t,o)}),x.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async o=>{const e=x.opts().config,t=await r(e);await h(t,o)}),x.command("rename-key <oldKey> <newKey>").description("Rename a translation key across all source files and translation files.").option("--dry-run","Preview changes without modifying files").action(async(o,e,t)=>{try{const n=x.opts().config,a=await r(n),c=await w(a,o,e,t);c.success||(c.conflicts&&(console.error(i.red("\n❌ Conflicts detected:")),c.conflicts.forEach(o=>console.error(` - ${o}`))),c.error&&console.error(i.red(`\n❌ ${c.error}`)),process.exit(1));0===c.sourceFiles.reduce((o,e)=>o+e.changes,0)&&console.log(i.yellow(`\n⚠️ No usages found for "${o}"`))}catch(o){console.error(i.red("Error renaming key:"),o),process.exit(1)}}),x.parse(process.argv);const j=o=>Array.isArray(o)?o:o?[o]:[],k=o=>o&&"string"==typeof o?[o.replace(/\{\{[^}]+\}\}/g,"*")]:[],z=async(o=[])=>{const e=j(o),n=await Promise.all(e.map(o=>t(o||"",{nodir:!0})));return Array.from(new Set(n.flat()))};export{x as program};
@@ -1 +1 @@
1
- import{glob as e}from"glob";import{readFile as t}from"node:fs/promises";import{parse as r}from"@swc/core";import{extname as n}from"node:path";import{EventEmitter as s}from"node:events";import o from"chalk";import i from"ora";class a extends s{config;constructor(e){super({captureRejections:!0}),this.config=e}wrapError(e){const t="Linter failed to run: ";if(e instanceof Error){if(e.message.startsWith(t))return e;const r=new Error(`${t}${e.message}`);return r.stack=e.stack,r}return new Error(`${t}${String(e)}`)}async run(){const{config:s}=this;try{this.emit("progress",{message:"Finding source files to analyze..."});const o=["node_modules/**"],i=Array.isArray(s.extract.ignore)?s.extract.ignore:s.extract.ignore?[s.extract.ignore]:[],a=await e(s.extract.input,{ignore:[...o,...i]});this.emit("progress",{message:`Analyzing ${a.length} source files...`});let c=0;const l=new Map;for(const e of a){const o=await t(e,"utf-8"),i=n(e).toLowerCase(),a=".ts"===i||".tsx"===i||".mts"===i||".cts"===i,p=".tsx"===i,f=".jsx"===i;let m;try{m=await r(o,{syntax:a?"typescript":"ecmascript",tsx:p,jsx:f,decorators:!0})}catch(t){if(".ts"!==i||p){const e=this.wrapError(t);this.emit("error",e);continue}try{m=await r(o,{syntax:"typescript",tsx:!0,decorators:!0}),this.emit("progress",{message:`Parsed ${e} using TSX fallback`})}catch(e){const t=this.wrapError(e);this.emit("error",t);continue}}const g=u(m,o,s);g.length>0&&(c+=g.length,l.set(e,g))}const p={success:0===c,message:c>0?`Linter found ${c} potential issues.`:"No issues found.",files:Object.fromEntries(l.entries())};return this.emit("done",p),p}catch(e){const t=this.wrapError(e);throw this.emit("error",t),t}}}async function c(e){return new a(e).run()}async function l(e){const t=new a(e),r=i().start();t.on("progress",e=>{r.text=e.message});try{const{success:e,message:n,files:s}=await t.run();if(e)r.succeed(o.green.bold(n));else{r.fail(o.red.bold(n));for(const[e,t]of Object.entries(s))console.log(o.yellow(`\n${e}`)),t.forEach(({text:e,line:t})=>{console.log(` ${o.gray(`${t}:`)} ${o.red("Error:")} Found hardcoded string: "${e}"`)});process.exit(1)}}catch(e){const n=t.wrapError(e);r.fail(n.message),console.error(n),process.exit(1)}}const p=e=>/^(https|http|\/\/|^\/)/.test(e);function u(e,t,r){const n=[],s=[],o=e=>t.substring(0,e).split("\n").length,i=(r.extract.transComponents||["Trans"]).map(e=>e.toLowerCase()),a=["className","key","id","style","href","i18nKey","defaults","type","target"].map(e=>e.toLowerCase()),c=(r?.lint?.ignoredTags||r.extract.ignoredTags||[]).map(e=>e.toLowerCase()),l=new Set([...i,...["script","style","code"].map(e=>e.toLowerCase()),...c]),u=(r?.lint?.ignoredAttributes||r.extract.ignoredAttributes||[]).map(e=>e.toLowerCase()),f=new Set([...a,...u]),m=(r?.lint?.acceptedTags&&r.lint.acceptedTags.length>0?r.lint.acceptedTags:r?.extract?.acceptedTags&&r.extract.acceptedTags.length>0?r.extract.acceptedTags:null)?.map(e=>e.toLowerCase())??null,g=(r?.lint?.acceptedAttributes&&r.lint.acceptedAttributes.length>0?r.lint.acceptedAttributes:r?.extract?.acceptedAttributes&&r.extract.acceptedAttributes.length>0?r.extract.acceptedAttributes:null)?.map(e=>e.toLowerCase())??null,y=m?new Set(m):null,d=g?new Set(g):null,h=e=>{if(!e)return null;const t=e.name??e.opening?.name??e.opening?.name;if(!t)return e.opening?.name?h({name:e.opening.name}):null;const r=e=>{if(!e)return null;if("JSXIdentifier"===e.type&&(e.name||e.value))return e.name??e.value;if("Identifier"===e.type&&(e.name||e.value))return e.name??e.value;if("JSXMemberExpression"===e.type){const t=r(e.object),n=r(e.property);return t&&n?`${t}.${n}`:n??t}return e.name??e.value??e.property?.name??e.property?.value??null},n=r(t);return n?String(n):null},w=e=>{if(!e)return null;if("string"==typeof e)return e;if("JSXIdentifier"===e.type||"Identifier"===e.type){const t=e.name??e.value??e.raw??null;return t?String(t):null}if("JSXNamespacedName"===e.type)return w(e.name)??w(e.namespace);if("JSXMemberExpression"===e.type){const t=w(e.object),r=w(e.property);return t&&r?`${t}.${r}`:r??t}if(e.name||e.value||e.property)return e.name??e.value??e.property?.name??e.property?.value??null;try{const t=JSON.stringify(e),r=/"?(?:name|value)"?\s*:\s*"?([a-zA-Z0-9_\-:.$]+)"?/.exec(t);return r?r[1]:null}catch{return null}},x=e=>{for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=h(r);if(!e)continue;if(l.has(String(e).toLowerCase()))return!0}}if(y){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=h(r);if(!e)continue;return!y.has(String(e).toLowerCase())}}return!0}return!1},S=(e,t)=>{if(!e||"object"!=typeof e)return;const r=[...t,e];if("JSXText"===e.type)if(d&&!y);else{if(!x(r)){const t=e.value.trim();t&&t.length>1&&"..."!==t&&!p(t)&&isNaN(Number(t))&&!t.startsWith("{{")&&s.push(e)}}if("StringLiteral"===e.type){const t=r[r.length-2],n=x(r);if("JSXAttribute"===t?.type&&!n){const n=w(t.name),o=n?String(n).toLowerCase():null,i=r.slice(0,-2).reverse().find(e=>e&&"object"==typeof e&&("JSXElement"===e.type||"JSXOpeningElement"===e.type||"JSXSelfClosingElement"===e.type));if(y&&i){const e=h(i);if(!e||!y.has(String(e).toLowerCase()))return}else if(y&&!i)return;if(d?null!=o&&d.has(o):null!=o&&!f.has(o)){const t=e.value.trim();t&&"..."!==t&&!p(t)&&isNaN(Number(t))&&s.push(e)}}}for(const t of Object.keys(e)){if("span"===t)continue;const n=e[t];Array.isArray(n)?n.forEach(e=>S(e,r)):n&&"object"==typeof n&&S(n,r)}};S(e,[]);let b=0;for(const e of s){const r=e.raw??e.value,s=t.indexOf(r,b);s>-1&&(n.push({text:e.value.trim(),line:o(s)}),b=s+r.length)}return n}export{a as Linter,c as runLinter,l as runLinterCli};
1
+ import{glob as e}from"glob";import{readFile as t}from"node:fs/promises";import{parse as r}from"@swc/core";import{extname as n}from"node:path";import{EventEmitter as s}from"node:events";import o from"chalk";import a from"ora";const i=["a","abbr","address","article","aside","bdi","bdo","blockquote","button","caption","cite","code","data","dd","del","details","dfn","dialog","div","dt","em","figcaption","footer","h1","h2","h3","h4","h5","h6","header","img","ins","kbd","label","legend","li","main","mark","nav","option","output","p","pre","q","s","samp","section","small","span","strong","sub","summary","sup","td","textarea","th","time","title","var"].map(e=>e.toLowerCase()),c=["abbr","accesskey","alt","aria-description","aria-label","aria-placeholder","aria-roledescription","aria-valuetext","content","label","placeholder","summary","title"].map(e=>e.toLowerCase()),l=["className","key","id","style","href","i18nKey","defaults","type","target"].map(e=>e.toLowerCase()),p=["script","style","code"];class u extends s{config;constructor(e){super({captureRejections:!0}),this.config=e}wrapError(e){const t="Linter failed to run: ";if(e instanceof Error){if(e.message.startsWith(t))return e;const r=new Error(`${t}${e.message}`);return r.stack=e.stack,r}return new Error(`${t}${String(e)}`)}async run(){const{config:s}=this;try{this.emit("progress",{message:"Finding source files to analyze..."});const o=["node_modules/**"],a=Array.isArray(s.extract.ignore)?s.extract.ignore:s.extract.ignore?[s.extract.ignore]:[],i=await e(s.extract.input,{ignore:[...o,...a]});this.emit("progress",{message:`Analyzing ${i.length} source files...`});let c=0;const l=new Map;for(const e of i){const o=await t(e,"utf-8"),a=n(e).toLowerCase(),i=".ts"===a||".tsx"===a||".mts"===a||".cts"===a,p=".tsx"===a,u=".jsx"===a;let m;try{m=await r(o,{syntax:i?"typescript":"ecmascript",tsx:p,jsx:u,decorators:!0})}catch(t){if(".ts"!==a||p){const e=this.wrapError(t);this.emit("error",e);continue}try{m=await r(o,{syntax:"typescript",tsx:!0,decorators:!0}),this.emit("progress",{message:`Parsed ${e} using TSX fallback`})}catch(e){const t=this.wrapError(e);this.emit("error",t);continue}}const f=d(m,o,s);f.length>0&&(c+=f.length,l.set(e,f))}const p={success:0===c,message:c>0?`Linter found ${c} potential issues.`:"No issues found.",files:Object.fromEntries(l.entries())};return this.emit("done",p),p}catch(e){const t=this.wrapError(e);throw this.emit("error",t),t}}}async function m(e){return new u(e).run()}async function f(e){const t=new u(e),r=a().start();t.on("progress",e=>{r.text=e.message});try{const{success:e,message:n,files:s}=await t.run();if(e)r.succeed(o.green.bold(n));else{r.fail(o.red.bold(n));for(const[e,t]of Object.entries(s))console.log(o.yellow(`\n${e}`)),t.forEach(({text:e,line:t})=>{console.log(` ${o.gray(`${t}:`)} ${o.red("Error:")} Found hardcoded string: "${e}"`)});process.exit(1)}}catch(e){const n=t.wrapError(e);r.fail(n.message),console.error(n),process.exit(1)}}const g=e=>/^(https|http|\/\/|^\/)/.test(e);function d(e,t,r){const n=[],s=[],o=e=>t.substring(0,e).split("\n").length,a=(r.extract.transComponents||["Trans"]).map(e=>e.toLowerCase()),u=(r?.lint?.ignoredTags||r.extract.ignoredTags||[]).map(e=>e.toLowerCase()),m=new Set([...a,...p.map(e=>e.toLowerCase()),...u]),f=(r?.lint?.ignoredAttributes||r.extract.ignoredAttributes||[]).map(e=>e.toLowerCase()),d=new Set([...l,...f]),y=r?.lint?.acceptedTags?r.lint.acceptedTags:null,h=r?.extract?.acceptedTags?r.extract.acceptedTags:null,b=(y??h??i)?.map(e=>e.toLowerCase())??null,w=r?.lint?.acceptedAttributes?r.lint.acceptedAttributes:null,x=r?.extract?.acceptedAttributes?r.extract.acceptedAttributes:null,S=(w??x??c)?.map(e=>e.toLowerCase())??null,E=b&&b.length>0?new Set(b):null,v=S&&S.length>0?new Set(S):null,C=e=>{if(!e)return null;const t=e.name??e.opening?.name??e.opening?.name;if(!t)return e.opening?.name?C({name:e.opening.name}):null;const r=e=>{if(!e)return null;if("JSXIdentifier"===e.type&&(e.name||e.value))return e.name??e.value;if("Identifier"===e.type&&(e.name||e.value))return e.name??e.value;if("JSXMemberExpression"===e.type){const t=r(e.object),n=r(e.property);return t&&n?`${t}.${n}`:n??t}return e.name??e.value??e.property?.name??e.property?.value??null},n=r(t);return n?String(n):null},J=e=>{if(!e)return null;if("string"==typeof e)return e;if("JSXIdentifier"===e.type||"Identifier"===e.type){const t=e.name??e.value??e.raw??null;return t?String(t):null}if("JSXNamespacedName"===e.type)return J(e.name)??J(e.namespace);if("JSXMemberExpression"===e.type){const t=J(e.object),r=J(e.property);return t&&r?`${t}.${r}`:r??t}if(e.name||e.value||e.property)return e.name??e.value??e.property?.name??e.property?.value??null;try{const t=JSON.stringify(e),r=/"?(?:name|value)"?\s*:\s*"?([a-zA-Z0-9_\-:.$]+)"?/.exec(t);return r?r[1]:null}catch{return null}},L=e=>{for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=C(r);if(!e)continue;if(m.has(String(e).toLowerCase()))return!0}}if(E){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=C(r);if(!e)continue;return!E.has(String(e).toLowerCase())}}return!0}return!1},X=(e,t)=>{if(!e||"object"!=typeof e)return;const r=[...t,e];if("JSXText"===e.type)if(v&&!E);else{if(!L(r)){const t=e.value.trim();t&&t.length>1&&"..."!==t&&!g(t)&&isNaN(Number(t))&&!t.startsWith("{{")&&s.push(e)}}if("StringLiteral"===e.type){const t=r[r.length-2],n=L(r);if("JSXAttribute"===t?.type&&!n){const n=J(t.name),o=n?String(n).toLowerCase():null,a=r.slice(0,-2).reverse().find(e=>e&&"object"==typeof e&&("JSXElement"===e.type||"JSXOpeningElement"===e.type||"JSXSelfClosingElement"===e.type));if(E&&a){const e=C(a);if(!e||!E.has(String(e).toLowerCase()))return}else if(E&&!a)return;if(v?null!=o&&v.has(o):null!=o&&!d.has(o)){const t=e.value.trim();t&&"..."!==t&&!g(t)&&isNaN(Number(t))&&s.push(e)}}}for(const t of Object.keys(e)){if("span"===t)continue;const n=e[t];Array.isArray(n)?n.forEach(e=>X(e,r)):n&&"object"==typeof n&&X(n,r)}};X(e,[]);let $=0;for(const e of s){const r=e.raw??e.value,s=t.indexOf(r,$);s>-1&&(n.push({text:e.value.trim(),line:o(s)}),$=s+r.length)}return n}export{u as Linter,m as runLinter,f as runLinterCli};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.25.0",
3
+ "version": "1.25.1",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE;QAAC;YACT,OAAO,EAAE,MAAM,CAAC;SACjB;KAAC,CAAC;IACH,IAAI,EAAE;QAAC;YACL,OAAO,EAAE,OAAO,CAAC;YACjB,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;SAC1C;KAAC,CAAC;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACvB,CAAA;AAED,qBAAa,MAAO,SAAQ,YAAY,CAAC,cAAc,CAAC;IACtD,OAAO,CAAC,MAAM,CAAsB;gBAEvB,MAAM,EAAE,oBAAoB;IAKzC,SAAS,CAAE,KAAK,EAAE,OAAO;IAanB,GAAG;;;;;;;CA2EV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,SAAS,CAAE,MAAM,EAAE,oBAAoB;;;;;;GAE5D;AAED,wBAAsB,YAAY,CAAE,MAAM,EAAE,oBAAoB,iBA4B/D;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;CACd"}
1
+ {"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE;QAAC;YACT,OAAO,EAAE,MAAM,CAAC;SACjB;KAAC,CAAC;IACH,IAAI,EAAE;QAAC;YACL,OAAO,EAAE,OAAO,CAAC;YACjB,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;SAC1C;KAAC,CAAC;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACvB,CAAA;AASD,qBAAa,MAAO,SAAQ,YAAY,CAAC,cAAc,CAAC;IACtD,OAAO,CAAC,MAAM,CAAsB;gBAEvB,MAAM,EAAE,oBAAoB;IAKzC,SAAS,CAAE,KAAK,EAAE,OAAO;IAanB,GAAG;;;;;;;CA2EV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,SAAS,CAAE,MAAM,EAAE,oBAAoB;;;;;;GAE5D;AAED,wBAAsB,YAAY,CAAE,MAAM,EAAE,oBAAoB,iBA4B/D;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;CACd"}
package/types/types.d.ts CHANGED
@@ -63,9 +63,19 @@ export interface I18nextToolkitConfig {
63
63
  ignoredAttributes?: string[];
64
64
  /** A list of JSX tag names whose content should be ignored when linting (e.g., 'code', 'pre'). */
65
65
  ignoredTags?: string[];
66
- /** for linting: Optional accept-list of JSX attribute names to exclusively lint (takes precedence over ignoredAttributes). */
66
+ /** for linting: Optional accept-list of JSX attribute names to exclusively lint (takes precedence over ignoredAttributes).
67
+ *
68
+ * If not provided (and no `extract.acceptedAttributes` is set), the linter will fall back to a recommended
69
+ * built-in accepted-list of common translatable attributes (e.g. `alt`, `title`, `placeholder`, `aria-label`, ...).
70
+ * See README for the exact recommended list.
71
+ */
67
72
  acceptedAttributes?: string[];
68
- /** for linting: Optional accept-list of JSX tag names to exclusively lint (takes precedence over ignoredTags). */
73
+ /** for linting: Optional accept-list of JSX tag names to exclusively lint (takes precedence over ignoredTags).
74
+ *
75
+ * If not provided (and no `extract.acceptedTags` is set), the linter will fall back to a recommended
76
+ * built-in accepted-list of common content-bearing tags (e.g. `p`, `span`, `div`, `button`, `label`, ...).
77
+ * See README for the exact recommended list.
78
+ */
69
79
  acceptedTags?: string[];
70
80
  /** HTML tags to preserve in Trans component serialization (default: ['br', 'strong', 'i']) */
71
81
  transKeepBasicHtmlNodesFor?: string[];
@@ -115,9 +125,19 @@ export interface I18nextToolkitConfig {
115
125
  ignoredAttributes?: string[];
116
126
  /** A list of JSX tag names whose content should be ignored when linting (e.g., 'code', 'pre'). */
117
127
  ignoredTags?: string[];
118
- /** Optional accept-list of JSX attribute names to exclusively lint (takes precedence over ignoredAttributes). */
128
+ /** for linting: Optional accept-list of JSX attribute names to exclusively lint (takes precedence over ignoredAttributes).
129
+ *
130
+ * If not provided (and no `extract.acceptedAttributes` is set), the linter will fall back to a recommended
131
+ * built-in accepted-list of common translatable attributes (e.g. `alt`, `title`, `placeholder`, `aria-label`, ...).
132
+ * See README for the exact recommended list.
133
+ */
119
134
  acceptedAttributes?: string[];
120
- /** Optional accept-list of JSX tag names to exclusively lint (takes precedence over ignoredTags). */
135
+ /** for linting: Optional accept-list of JSX tag names to exclusively lint (takes precedence over ignoredTags).
136
+ *
137
+ * If not provided (and no `extract.acceptedTags` is set), the linter will fall back to a recommended
138
+ * built-in accepted-list of common content-bearing tags (e.g. `p`, `span`, `div`, `button`, `label`, ...).
139
+ * See README for the exact recommended list.
140
+ */
121
141
  acceptedTags?: string[];
122
142
  };
123
143
  /** Configuration options for TypeScript type generation */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;A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