i18next-cli 1.11.12 → 1.11.13

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/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.11.13](https://github.com/i18next/i18next-cli/compare/v1.11.12...v1.11.13) - 2025-10-22
9
+
10
+ - Fix: Stop infinite watch loops by properly honoring extract.ignore patterns [#70](https://github.com/i18next/i18next-cli/issues/70)
11
+
8
12
  ## [1.11.12](https://github.com/i18next/i18next-cli/compare/v1.11.11...v1.11.12) - 2025-10-21
9
13
 
10
14
  - further improve jsx-parser [#66](https://github.com/i18next/i18next-cli/issues/66)
package/dist/cjs/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=require("commander"),t=require("chokidar"),n=require("glob"),o=require("chalk"),i=require("./config.js"),a=require("./heuristic-config.js"),r=require("./extractor/core/extractor.js");require("node:path"),require("node:fs/promises"),require("jiti");var c=require("./types-generator.js"),s=require("./syncer.js"),l=require("./migrator.js"),u=require("./init.js"),d=require("./linter.js"),g=require("./status.js"),p=require("./locize.js");const f=new e.Command;f.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.11.12"),f.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 o=await i.ensureConfig(),a=async()=>{const t=await r.runExtractor(o,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:!!e.syncPrimary});return e.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await a(),e.watch){console.log("\nWatching for changes...");t.watch(await n.glob(o.extract.input),{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)}}),f.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,t)=>{let n=await i.loadConfig();if(!n){console.log(o.blue("No config file found. Attempting to detect project structure..."));const e=await a.detectConfig();e||(console.error(o.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${o.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(o.green("Project structure detected successfully!")),n=e}await g.runStatus(n,{detail:e,namespace:t.namespace})}),f.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 o=await i.ensureConfig(),a=()=>c.runTypesGenerator(o);if(await a(),e.watch){console.log("\nWatching for changes...");t.watch(await n.glob(o.types?.input||[]),{persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}),f.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=await i.ensureConfig();await s.runSyncer(e)}),f.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await l.runMigrator(e)}),f.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(u.runInit),f.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 r=async()=>{let e=await i.loadConfig();if(!e){console.log(o.blue("No config file found. Attempting to detect project structure..."));const t=await a.detectConfig();t||(console.error(o.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${o.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(o.green("Project structure detected successfully!")),e=t}await d.runLinter(e)};if(await r(),e.watch){console.log("\nWatching for changes...");const e=await i.loadConfig();if(e?.extract?.input){t.watch(await n.glob(e.extract.input),{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),r()})}}}),f.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 t=await i.ensureConfig();await p.runLocizeSync(t,e)}),f.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const t=await i.ensureConfig();await p.runLocizeDownload(t,e)}),f.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const t=await i.ensureConfig();await p.runLocizeMigrate(t,e)}),f.parse(process.argv);
2
+ "use strict";var e=require("commander"),t=require("chokidar"),n=require("chalk"),o=require("./config.js"),i=require("./heuristic-config.js"),r=require("./extractor/core/extractor.js");require("glob"),require("node:path"),require("node:fs/promises"),require("jiti");var a=require("./types-generator.js"),c=require("./syncer.js"),s=require("./migrator.js"),l=require("./init.js"),u=require("./linter.js"),g=require("./status.js"),d=require("./locize.js");const p=new e.Command;p.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.11.13"),p.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 n=await o.ensureConfig(),i=async()=>{const t=await r.runExtractor(n,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:!!e.syncPrimary});return e.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await i(),e.watch){console.log("\nWatching for changes...");const e=[/node_modules/,...Array.isArray(n.extract.ignore)?n.extract.ignore:n.extract.ignore?[n.extract.ignore]:[]],o=n.extract.input||[];t.watch(o,{ignored:e,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),i()})}}catch(e){console.error("Error running extractor:",e),process.exit(1)}}),p.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,t)=>{let r=await o.loadConfig();if(!r){console.log(n.blue("No config file found. Attempting to detect project structure..."));const e=await i.detectConfig();e||(console.error(n.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${n.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(n.green("Project structure detected successfully!")),r=e}await g.runStatus(r,{detail:e,namespace:t.namespace})}),p.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 n=await o.ensureConfig(),i=()=>a.runTypesGenerator(n);if(await i(),e.watch){console.log("\nWatching for changes...");const e=[/node_modules/,...Array.isArray(n.extract?.ignore)?n.extract.ignore:n.extract?.ignore?[n.extract?.ignore]:[]],o=n.types?.input||[];t.watch(o,{ignored:e,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),i()})}}),p.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=await o.ensureConfig();await c.runSyncer(e)}),p.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await s.runMigrator(e)}),p.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(l.runInit),p.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 r=async()=>{let e=await o.loadConfig();if(!e){console.log(n.blue("No config file found. Attempting to detect project structure..."));const t=await i.detectConfig();t||(console.error(n.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${n.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(n.green("Project structure detected successfully!")),e=t}await u.runLinter(e)};if(await r(),e.watch){console.log("\nWatching for changes...");const e=await o.loadConfig();if(e?.extract?.input){const n=[/node_modules/,...Array.isArray(e.extract.ignore)?e.extract.ignore:e.extract.ignore?[e.extract.ignore]:[]],o=e.extract.input||[];t.watch(o,{ignored:n,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),r()})}}}),p.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 t=await o.ensureConfig();await d.runLocizeSync(t,e)}),p.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const t=await o.ensureConfig();await d.runLocizeDownload(t,e)}),p.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const t=await o.ensureConfig();await d.runLocizeMigrate(t,e)}),p.parse(process.argv);
package/dist/esm/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Command as t}from"commander";import e from"chokidar";import{glob as o}from"glob";import n from"chalk";import{ensureConfig as i,loadConfig as a}from"./config.js";import{detectConfig as c}from"./heuristic-config.js";import{runExtractor as r}from"./extractor/core/extractor.js";import"node:path";import"node:fs/promises";import"jiti";import{runTypesGenerator as s}from"./types-generator.js";import{runSyncer as l}from"./syncer.js";import{runMigrator as p}from"./migrator.js";import{runInit as m}from"./init.js";import{runLinter as d}from"./linter.js";import{runStatus as u}from"./status.js";import{runLocizeSync as f,runLocizeDownload as g,runLocizeMigrate as h}from"./locize.js";const y=new t;y.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.11.12"),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 t=>{try{const n=await i(),a=async()=>{const e=await r(n,{isWatchMode:!!t.watch,isDryRun:!!t.dryRun,syncPrimaryWithDefaults:!!t.syncPrimary});return t.ci&&!e?(console.log("✅ No files were updated."),process.exit(0)):t.ci&&e&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),e};if(await a(),t.watch){console.log("\nWatching for changes...");e.watch(await o(n.extract.input),{ignored:/node_modules/,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),a()})}}catch(t){console.error("Error running extractor:",t),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(t,e)=>{let o=await a();if(!o){console.log(n.blue("No config file found. Attempting to detect project structure..."));const t=await c();t||(console.error(n.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${n.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(n.green("Project structure detected successfully!")),o=t}await u(o,{detail:t,namespace:e.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 t=>{const n=await i(),a=()=>s(n);if(await a(),t.watch){console.log("\nWatching for changes...");e.watch(await o(n.types?.input||[]),{persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),a()})}}),y.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const t=await i();await l(t)}),y.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async t=>{await p(t)}),y.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(m),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 t=>{const i=async()=>{let t=await a();if(!t){console.log(n.blue("No config file found. Attempting to detect project structure..."));const e=await c();e||(console.error(n.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${n.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(n.green("Project structure detected successfully!")),t=e}await d(t)};if(await i(),t.watch){console.log("\nWatching for changes...");const t=await a();if(t?.extract?.input){e.watch(await o(t.extract.input),{ignored:/node_modules/,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),i()})}}}),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 t=>{const e=await i();await f(e,t)}),y.command("locize-download").description("Download all translations from your locize project.").action(async t=>{const e=await i();await g(e,t)}),y.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async t=>{const e=await i();await h(e,t)}),y.parse(process.argv);
2
+ import{Command as t}from"commander";import e from"chokidar";import o from"chalk";import{ensureConfig as n,loadConfig as i}from"./config.js";import{detectConfig as a}from"./heuristic-config.js";import{runExtractor as r}from"./extractor/core/extractor.js";import"glob";import"node:path";import"node:fs/promises";import"jiti";import{runTypesGenerator as c}from"./types-generator.js";import{runSyncer as s}from"./syncer.js";import{runMigrator as l}from"./migrator.js";import{runInit as p}from"./init.js";import{runLinter as d}from"./linter.js";import{runStatus as m}from"./status.js";import{runLocizeSync as g,runLocizeDownload as u,runLocizeMigrate as f}from"./locize.js";const y=new t;y.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.11.13"),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 t=>{try{const o=await n(),i=async()=>{const e=await r(o,{isWatchMode:!!t.watch,isDryRun:!!t.dryRun,syncPrimaryWithDefaults:!!t.syncPrimary});return t.ci&&!e?(console.log("✅ No files were updated."),process.exit(0)):t.ci&&e&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),e};if(await i(),t.watch){console.log("\nWatching for changes...");const t=[/node_modules/,...Array.isArray(o.extract.ignore)?o.extract.ignore:o.extract.ignore?[o.extract.ignore]:[]],n=o.extract.input||[];e.watch(n,{ignored:t,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),i()})}}catch(t){console.error("Error running extractor:",t),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(t,e)=>{let n=await i();if(!n){console.log(o.blue("No config file found. Attempting to detect project structure..."));const t=await a();t||(console.error(o.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${o.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(o.green("Project structure detected successfully!")),n=t}await m(n,{detail:t,namespace:e.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 t=>{const o=await n(),i=()=>c(o);if(await i(),t.watch){console.log("\nWatching for changes...");const t=[/node_modules/,...Array.isArray(o.extract?.ignore)?o.extract.ignore:o.extract?.ignore?[o.extract?.ignore]:[]],n=o.types?.input||[];e.watch(n,{ignored:t,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),i()})}}),y.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const t=await n();await s(t)}),y.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async t=>{await l(t)}),y.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(p),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 t=>{const n=async()=>{let t=await i();if(!t){console.log(o.blue("No config file found. Attempting to detect project structure..."));const e=await a();e||(console.error(o.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${o.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(o.green("Project structure detected successfully!")),t=e}await d(t)};if(await n(),t.watch){console.log("\nWatching for changes...");const t=await i();if(t?.extract?.input){const o=[/node_modules/,...Array.isArray(t.extract.ignore)?t.extract.ignore:t.extract.ignore?[t.extract.ignore]:[]],i=t.extract.input||[];e.watch(i,{ignored:o,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),n()})}}}),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 t=>{const e=await n();await g(e,t)}),y.command("locize-download").description("Download all translations from your locize project.").action(async t=>{const e=await n();await u(e,t)}),y.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async t=>{const e=await n();await f(e,t)}),y.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.11.12",
3
+ "version": "1.11.13",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.ts CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { Command } from 'commander'
4
4
  import chokidar from 'chokidar'
5
- import { glob } from 'glob'
6
5
  import chalk from 'chalk'
7
6
  import { loadConfig, ensureConfig } from './config'
8
7
  import { detectConfig } from './heuristic-config'
@@ -21,7 +20,7 @@ const program = new Command()
21
20
  program
22
21
  .name('i18next-cli')
23
22
  .description('A unified, high-performance i18next CLI.')
24
- .version('1.11.12')
23
+ .version('1.11.13')
25
24
 
26
25
  program
27
26
  .command('extract')
@@ -58,8 +57,14 @@ program
58
57
  // If in watch mode, set up the chokidar watcher
59
58
  if (options.watch) {
60
59
  console.log('\nWatching for changes...')
61
- const watcher = chokidar.watch(await glob(config.extract.input), {
62
- ignored: /node_modules/,
60
+ // Respect configured ignore patterns and pass the original glob(s) to chokidar
61
+ const ignoredPatterns = [
62
+ /node_modules/,
63
+ ...(Array.isArray(config.extract.ignore) ? config.extract.ignore : (config.extract.ignore ? [config.extract.ignore] : [])),
64
+ ]
65
+ const watchTargets = config.extract.input || []
66
+ const watcher = chokidar.watch(watchTargets, {
67
+ ignored: ignoredPatterns,
63
68
  persistent: true,
64
69
  })
65
70
  watcher.on('change', path => {
@@ -105,7 +110,14 @@ program
105
110
 
106
111
  if (options.watch) {
107
112
  console.log('\nWatching for changes...')
108
- const watcher = chokidar.watch(await glob(config.types?.input || []), {
113
+ // Use the configured input patterns and respect extract.ignore if present
114
+ const ignoredPatterns = [
115
+ /node_modules/,
116
+ ...(Array.isArray(config.extract?.ignore) ? config.extract.ignore : (config.extract?.ignore ? [config.extract?.ignore] : [])),
117
+ ]
118
+ const watchTargets = config.types?.input || []
119
+ const watcher = chokidar.watch(watchTargets, {
120
+ ignored: ignoredPatterns,
109
121
  persistent: true,
110
122
  })
111
123
  watcher.on('change', path => {
@@ -166,8 +178,13 @@ program
166
178
  // Re-load the config to get the correct input paths for the watcher
167
179
  const config = await loadConfig()
168
180
  if (config?.extract?.input) {
169
- const watcher = chokidar.watch(await glob(config.extract.input), {
170
- ignored: /node_modules/,
181
+ const ignoredPatterns = [
182
+ /node_modules/,
183
+ ...(Array.isArray(config.extract.ignore) ? config.extract.ignore : (config.extract.ignore ? [config.extract.ignore] : [])),
184
+ ]
185
+ const watchTargets = config.extract.input || []
186
+ const watcher = chokidar.watch(watchTargets, {
187
+ ignored: ignoredPatterns,
171
188
  persistent: true,
172
189
  })
173
190
  watcher.on('change', path => {