i18next-cli 1.58.1 → 1.58.2
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 +1 -1
- package/dist/cjs/instrumenter/core/transformer.js +52 -8
- package/dist/cjs/types-generator.js +3 -3
- package/dist/esm/cli.js +1 -1
- package/dist/esm/instrumenter/core/transformer.js +52 -8
- package/dist/esm/types-generator.js +3 -3
- package/package.json +15 -15
- package/tsconfig.json +1 -1
- package/types/instrumenter/core/transformer.d.ts.map +1 -1
package/dist/cjs/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ const program = new commander.Command();
|
|
|
32
32
|
program
|
|
33
33
|
.name('i18next-cli')
|
|
34
34
|
.description('A unified, high-performance i18next CLI.')
|
|
35
|
-
.version('1.58.
|
|
35
|
+
.version('1.58.2'); // This string is replaced with the actual version at build time by rollup
|
|
36
36
|
// new: global config override option
|
|
37
37
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
38
38
|
program
|
|
@@ -328,18 +328,62 @@ function addImportStatements(s, content, needs) {
|
|
|
328
328
|
if (content.startsWith('#!')) {
|
|
329
329
|
insertPos = content.indexOf('\n') + 1;
|
|
330
330
|
}
|
|
331
|
-
// Find the end of the last import statement
|
|
332
|
-
|
|
331
|
+
// Find the end of the last import statement. Imports may span multiple lines
|
|
332
|
+
// (e.g. `import {\n CCol,\n} from '...'`), so we can't treat each `import`
|
|
333
|
+
// line as a complete statement — we scan to the real end of each declaration.
|
|
334
|
+
const importStartRegex = /^import\b/gm;
|
|
333
335
|
let match;
|
|
334
|
-
while ((match =
|
|
335
|
-
const endOfImport = match.index
|
|
336
|
-
if (endOfImport > insertPos)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
while ((match = importStartRegex.exec(content)) !== null) {
|
|
337
|
+
const endOfImport = findImportStatementEnd(content, match.index);
|
|
338
|
+
if (endOfImport > insertPos)
|
|
339
|
+
insertPos = endOfImport;
|
|
340
|
+
// Skip past this statement so we don't match `import` lines inside it.
|
|
341
|
+
importStartRegex.lastIndex = endOfImport;
|
|
340
342
|
}
|
|
341
343
|
s.appendRight(insertPos, importStatement);
|
|
342
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Returns the offset just past the end of the import statement that begins at
|
|
347
|
+
* `start`, handling multi-line imports with `{ ... }` clauses. The statement
|
|
348
|
+
* ends at the first newline or `;` at brace depth 0, after its module-specifier
|
|
349
|
+
* string has been closed.
|
|
350
|
+
*/
|
|
351
|
+
function findImportStatementEnd(content, start) {
|
|
352
|
+
let depth = 0;
|
|
353
|
+
let stringChar = null;
|
|
354
|
+
let sawString = false;
|
|
355
|
+
for (let i = start; i < content.length; i++) {
|
|
356
|
+
const ch = content[i];
|
|
357
|
+
if (stringChar !== null) {
|
|
358
|
+
if (ch === '\\') {
|
|
359
|
+
i++;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (ch === stringChar) {
|
|
363
|
+
stringChar = null;
|
|
364
|
+
if (depth === 0)
|
|
365
|
+
sawString = true;
|
|
366
|
+
}
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (ch === '\'' || ch === '"' || ch === '`') {
|
|
370
|
+
stringChar = ch;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (ch === '{' || ch === '(' || ch === '[') {
|
|
374
|
+
depth++;
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if (ch === '}' || ch === ')' || ch === ']') {
|
|
378
|
+
depth--;
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (depth === 0 && sawString && (ch === '\n' || ch === ';')) {
|
|
382
|
+
return i + 1;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return content.length;
|
|
386
|
+
}
|
|
343
387
|
/**
|
|
344
388
|
* Augments an existing `import { ... } from 'react-i18next'` with any missing
|
|
345
389
|
* named exports (e.g. adds `Trans` when only `useTranslation` is imported).
|
|
@@ -29,10 +29,10 @@ async function loadFile(file) {
|
|
|
29
29
|
type: 'commonjs'
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
const exports
|
|
33
|
-
const module = { exports
|
|
32
|
+
const exports = {};
|
|
33
|
+
const module = { exports };
|
|
34
34
|
const context = vm.createContext({
|
|
35
|
-
exports
|
|
35
|
+
exports,
|
|
36
36
|
module,
|
|
37
37
|
require: (id) => require(id),
|
|
38
38
|
console,
|
package/dist/esm/cli.js
CHANGED
|
@@ -30,7 +30,7 @@ const program = new Command();
|
|
|
30
30
|
program
|
|
31
31
|
.name('i18next-cli')
|
|
32
32
|
.description('A unified, high-performance i18next CLI.')
|
|
33
|
-
.version('1.58.
|
|
33
|
+
.version('1.58.2'); // This string is replaced with the actual version at build time by rollup
|
|
34
34
|
// new: global config override option
|
|
35
35
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
36
36
|
program
|
|
@@ -326,18 +326,62 @@ function addImportStatements(s, content, needs) {
|
|
|
326
326
|
if (content.startsWith('#!')) {
|
|
327
327
|
insertPos = content.indexOf('\n') + 1;
|
|
328
328
|
}
|
|
329
|
-
// Find the end of the last import statement
|
|
330
|
-
|
|
329
|
+
// Find the end of the last import statement. Imports may span multiple lines
|
|
330
|
+
// (e.g. `import {\n CCol,\n} from '...'`), so we can't treat each `import`
|
|
331
|
+
// line as a complete statement — we scan to the real end of each declaration.
|
|
332
|
+
const importStartRegex = /^import\b/gm;
|
|
331
333
|
let match;
|
|
332
|
-
while ((match =
|
|
333
|
-
const endOfImport = match.index
|
|
334
|
-
if (endOfImport > insertPos)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
334
|
+
while ((match = importStartRegex.exec(content)) !== null) {
|
|
335
|
+
const endOfImport = findImportStatementEnd(content, match.index);
|
|
336
|
+
if (endOfImport > insertPos)
|
|
337
|
+
insertPos = endOfImport;
|
|
338
|
+
// Skip past this statement so we don't match `import` lines inside it.
|
|
339
|
+
importStartRegex.lastIndex = endOfImport;
|
|
338
340
|
}
|
|
339
341
|
s.appendRight(insertPos, importStatement);
|
|
340
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Returns the offset just past the end of the import statement that begins at
|
|
345
|
+
* `start`, handling multi-line imports with `{ ... }` clauses. The statement
|
|
346
|
+
* ends at the first newline or `;` at brace depth 0, after its module-specifier
|
|
347
|
+
* string has been closed.
|
|
348
|
+
*/
|
|
349
|
+
function findImportStatementEnd(content, start) {
|
|
350
|
+
let depth = 0;
|
|
351
|
+
let stringChar = null;
|
|
352
|
+
let sawString = false;
|
|
353
|
+
for (let i = start; i < content.length; i++) {
|
|
354
|
+
const ch = content[i];
|
|
355
|
+
if (stringChar !== null) {
|
|
356
|
+
if (ch === '\\') {
|
|
357
|
+
i++;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (ch === stringChar) {
|
|
361
|
+
stringChar = null;
|
|
362
|
+
if (depth === 0)
|
|
363
|
+
sawString = true;
|
|
364
|
+
}
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (ch === '\'' || ch === '"' || ch === '`') {
|
|
368
|
+
stringChar = ch;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (ch === '{' || ch === '(' || ch === '[') {
|
|
372
|
+
depth++;
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (ch === '}' || ch === ')' || ch === ']') {
|
|
376
|
+
depth--;
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
if (depth === 0 && sawString && (ch === '\n' || ch === ';')) {
|
|
380
|
+
return i + 1;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return content.length;
|
|
384
|
+
}
|
|
341
385
|
/**
|
|
342
386
|
* Augments an existing `import { ... } from 'react-i18next'` with any missing
|
|
343
387
|
* named exports (e.g. adds `Trans` when only `useTranslation` is imported).
|
|
@@ -27,10 +27,10 @@ async function loadFile(file) {
|
|
|
27
27
|
type: 'commonjs'
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
const exports
|
|
31
|
-
const module = { exports
|
|
30
|
+
const exports = {};
|
|
31
|
+
const module = { exports };
|
|
32
32
|
const context = vm.createContext({
|
|
33
|
-
exports
|
|
33
|
+
exports,
|
|
34
34
|
module,
|
|
35
35
|
require: (id) => require(id),
|
|
36
36
|
console,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18next-cli",
|
|
3
|
-
"version": "1.58.
|
|
3
|
+
"version": "1.58.2",
|
|
4
4
|
"description": "A unified, high-performance i18next CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -56,36 +56,36 @@
|
|
|
56
56
|
"@rollup/plugin-terser": "^1.0.0",
|
|
57
57
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
58
58
|
"@types/inquirer": "^9.0.9",
|
|
59
|
-
"@types/node": "^25.
|
|
60
|
-
"@types/react": "^19.2.
|
|
61
|
-
"@typescript-eslint/parser": "^8.
|
|
62
|
-
"@vitest/coverage-v8": "^4.1.
|
|
59
|
+
"@types/node": "^25.9.1",
|
|
60
|
+
"@types/react": "^19.2.15",
|
|
61
|
+
"@typescript-eslint/parser": "^8.60.0",
|
|
62
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
63
63
|
"eslint": "^9.39.4",
|
|
64
64
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
65
65
|
"eslint-plugin-import": "^2.32.0",
|
|
66
|
-
"memfs": "^4.57.
|
|
66
|
+
"memfs": "^4.57.3",
|
|
67
67
|
"neostandard": "^0.13.0",
|
|
68
|
-
"rollup": "^4.60.
|
|
68
|
+
"rollup": "^4.60.4",
|
|
69
69
|
"typescript": "^6.0.3",
|
|
70
70
|
"unplugin-swc": "^1.5.9",
|
|
71
|
-
"vitest": "^4.1.
|
|
71
|
+
"vitest": "^4.1.7"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@croct/json5-parser": "^0.2.2",
|
|
75
|
-
"@swc/core": "^1.15.
|
|
75
|
+
"@swc/core": "^1.15.40",
|
|
76
76
|
"chokidar": "^5.0.0",
|
|
77
77
|
"commander": "^14.0.3",
|
|
78
78
|
"execa": "^9.6.1",
|
|
79
79
|
"glob": "^13.0.6",
|
|
80
80
|
"i18next-resources-for-ts": "^2.1.0",
|
|
81
|
-
"inquirer": "^13.4.
|
|
82
|
-
"jiti": "^2.
|
|
81
|
+
"inquirer": "^13.4.3",
|
|
82
|
+
"jiti": "^2.7.0",
|
|
83
83
|
"jsonc-parser": "^3.3.1",
|
|
84
84
|
"magic-string": "^0.30.21",
|
|
85
85
|
"minimatch": "^10.2.5",
|
|
86
|
-
"ora": "^9.
|
|
87
|
-
"react": "^19.2.
|
|
88
|
-
"react-i18next": "^17.0.
|
|
89
|
-
"yaml": "^2.
|
|
86
|
+
"ora": "^9.4.0",
|
|
87
|
+
"react": "^19.2.6",
|
|
88
|
+
"react-i18next": "^17.0.8",
|
|
89
|
+
"yaml": "^2.9.0"
|
|
90
90
|
}
|
|
91
91
|
}
|
package/tsconfig.json
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
47
47
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
48
48
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
49
|
-
|
|
49
|
+
"types": ["node"], /* Type declaration files to be included in compilation. */
|
|
50
50
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
51
51
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
52
52
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/core/transformer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAGnI,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAA;IAC7C,6EAA6E;IAC7E,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAChC,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAC3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,eAAe,EAAE,EAC7B,OAAO,EAAE,kBAAkB,GAC1B,eAAe,CAyLjB;
|
|
1
|
+
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/core/transformer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAGnI,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAA;IAC7C,6EAA6E;IAC7E,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAChC,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAC3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,eAAe,EAAE,EAC7B,OAAO,EAAE,kBAAkB,GAC1B,eAAe,CAyLjB;AAkPD;;GAEG;AACH,wBAAgB,YAAY,CAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwB1F"}
|