i18ntk 2.3.2 → 2.3.4
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/README.md +7 -6
- package/package.json +6 -4
- package/utils/config-manager.js +140 -28
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# i18ntk v2.3.
|
|
1
|
+
# i18ntk v2.3.4
|
|
2
2
|
|
|
3
3
|
Zero-dependency internationalization toolkit for setup, scanning, analysis, validation, usage tracking, and translation completion.
|
|
4
4
|
|
|
@@ -9,14 +9,15 @@ Zero-dependency internationalization toolkit for setup, scanning, analysis, vali
|
|
|
9
9
|
[](https://nodejs.org)
|
|
10
10
|
[](https://www.npmjs.com/package/i18ntk)
|
|
11
11
|
[](LICENSE)
|
|
12
|
-
[](https://socket.dev/npm/package/i18ntk/overview/2.3.4)
|
|
13
13
|
|
|
14
14
|
## Upgrade Notice
|
|
15
15
|
|
|
16
|
-
Versions earlier than `2.3.
|
|
17
|
-
They are considered unsupported for production use. Upgrade to `2.3.
|
|
16
|
+
Versions earlier than `2.3.4` may contain known stability and security issues.
|
|
17
|
+
They are considered unsupported for production use. Upgrade to `2.3.4` or newer.
|
|
18
18
|
The CLI now checks npm registry metadata at startup and warns when your installed version is out of date.
|
|
19
19
|
Set `I18NTK_DISABLE_UPDATE_CHECK=true` to disable this warning in restricted/offline environments.
|
|
20
|
+
Set `I18NTK_DISABLE_AUTOSAVE=1` in server/runtime environments to keep config in memory and skip disk writes.
|
|
20
21
|
|
|
21
22
|
## What i18ntk Does
|
|
22
23
|
|
|
@@ -153,7 +154,7 @@ Example `.i18ntk-config`:
|
|
|
153
154
|
|
|
154
155
|
```json
|
|
155
156
|
{
|
|
156
|
-
"version": "2.3.
|
|
157
|
+
"version": "2.3.4",
|
|
157
158
|
"sourceDir": "./locales",
|
|
158
159
|
"i18nDir": "./locales",
|
|
159
160
|
"outputDir": "./i18ntk-reports",
|
|
@@ -176,7 +177,7 @@ See [docs/api/CONFIGURATION.md](docs/api/CONFIGURATION.md) for the full configur
|
|
|
176
177
|
- [Runtime API Guide](docs/runtime.md)
|
|
177
178
|
- [Scanner Guide](docs/scanner-guide.md)
|
|
178
179
|
- [Environment Variables](docs/environment-variables.md)
|
|
179
|
-
- [Migration Guide v2.3.
|
|
180
|
+
- [Migration Guide v2.3.4](docs/migration-guide-v2.3.4.md)
|
|
180
181
|
- [Optimization Prompt](docs/development/package-optimization-prompt.md)
|
|
181
182
|
|
|
182
183
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18ntk",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "🚀 The fastest internationalization toolkit with 97% performance boost! Zero-dependency, enterprise-grade internationalization for React, Vue, Angular, Python, Java, PHP & more. Features PIN protection, auto framework detection, 7+ UI languages, and comprehensive translation management. Perfect for startups to enterprises.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
},
|
|
228
228
|
"preferGlobal": true,
|
|
229
229
|
"versionInfo": {
|
|
230
|
-
"version": "2.3.
|
|
230
|
+
"version": "2.3.4",
|
|
231
231
|
"releaseDate": "12/04/2026",
|
|
232
232
|
"lastUpdated": "12/04/2026",
|
|
233
233
|
"maintainer": "Vlad Noskov",
|
|
@@ -238,7 +238,9 @@
|
|
|
238
238
|
"HOTFIX: Removed deprecated package-path fallback that caused production build warnings for non-exported subpaths.",
|
|
239
239
|
"CRITICAL FIX: Resolved sizing and usage-analysis regressions in v2 command flow.",
|
|
240
240
|
"PACKAGING: Reduced publish footprint by removing internal development scripts and legacy fixed-file artifacts.",
|
|
241
|
-
"SECURITY: Hardened release checks and added explicit support guidance to update from pre-2.3.
|
|
241
|
+
"SECURITY: Hardened release checks and added explicit support guidance to update from pre-2.3.4 versions.",
|
|
242
|
+
"CONFIG: Added cross-process file locking for .i18ntk-config writes to prevent production rename races.",
|
|
243
|
+
"CONFIG: Made autosave runtime-safe with non-throwing save failures and I18NTK_DISABLE_AUTOSAVE support.",
|
|
242
244
|
"CLI: Added npm registry version check with upgrade warning for out-of-date installs.",
|
|
243
245
|
"I18N: Completed internal UI locale parity and actionable untranslated-key cleanup across supported languages."
|
|
244
246
|
],
|
|
@@ -265,7 +267,7 @@
|
|
|
265
267
|
"spring-boot": ">=2.5.0",
|
|
266
268
|
"laravel": ">=8.0.0"
|
|
267
269
|
},
|
|
268
|
-
"supportPolicy": "Versions earlier than 2.3.
|
|
270
|
+
"supportPolicy": "Versions earlier than 2.3.4 may be unstable or insecure. Upgrade to 2.3.4 or newer."
|
|
269
271
|
},
|
|
270
272
|
"_comment": "This package is zero-dependency and uses only native Node.js modules"
|
|
271
273
|
}
|
package/utils/config-manager.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const os = require('os');
|
|
4
|
+
const crypto = require('crypto');
|
|
4
5
|
const SecurityUtils = require('./security');
|
|
5
6
|
|
|
6
7
|
// Determine package directory and user project root
|
|
@@ -9,8 +10,13 @@ const userProjectRoot = process.cwd();
|
|
|
9
10
|
|
|
10
11
|
// Always use current working directory for settings to support test environments
|
|
11
12
|
// This ensures config works correctly when tests change the working directory
|
|
12
|
-
const PROJECT_CONFIG_PATH = path.join(process.cwd(), '.i18ntk-config');
|
|
13
|
-
const PROJECT_SETTINGS_DIR = path.dirname(PROJECT_CONFIG_PATH);
|
|
13
|
+
const PROJECT_CONFIG_PATH = path.join(process.cwd(), '.i18ntk-config');
|
|
14
|
+
const PROJECT_SETTINGS_DIR = path.dirname(PROJECT_CONFIG_PATH);
|
|
15
|
+
const CONFIG_LOCK_PATH = `${PROJECT_CONFIG_PATH}.lock`;
|
|
16
|
+
const CONFIG_LOCK_TIMEOUT_MS = 5000;
|
|
17
|
+
const CONFIG_LOCK_STALE_MS = 15000;
|
|
18
|
+
const CONFIG_LOCK_RETRY_MS = 50;
|
|
19
|
+
let autosaveDisabledWarned = false;
|
|
14
20
|
|
|
15
21
|
// Setup tracking file
|
|
16
22
|
const SETUP_COMPLETED_FILE = path.join(PROJECT_SETTINGS_DIR, 'setup.json');
|
|
@@ -244,10 +250,69 @@ const DEFAULT_CONFIG = {
|
|
|
244
250
|
|
|
245
251
|
// Environment variable support has been removed in favor of exclusive .i18ntk-config configuration
|
|
246
252
|
|
|
247
|
-
let currentConfig = null;
|
|
248
|
-
let configLoadInProgress = false;
|
|
249
|
-
let recursionDepth = 0;
|
|
250
|
-
const MAX_RECURSION_DEPTH = 15; // Increased to handle legitimate sequential calls
|
|
253
|
+
let currentConfig = null;
|
|
254
|
+
let configLoadInProgress = false;
|
|
255
|
+
let recursionDepth = 0;
|
|
256
|
+
const MAX_RECURSION_DEPTH = 15; // Increased to handle legitimate sequential calls
|
|
257
|
+
let configSaveQueue = Promise.resolve();
|
|
258
|
+
|
|
259
|
+
function sleep(ms) {
|
|
260
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async function acquireConfigLock(timeoutMs = CONFIG_LOCK_TIMEOUT_MS) {
|
|
264
|
+
const start = Date.now();
|
|
265
|
+
let lockHandle = null;
|
|
266
|
+
|
|
267
|
+
while (!lockHandle) {
|
|
268
|
+
try {
|
|
269
|
+
lockHandle = await fs.promises.open(CONFIG_LOCK_PATH, 'wx');
|
|
270
|
+
await lockHandle.writeFile(String(process.pid), 'utf8');
|
|
271
|
+
break;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
if (!error || error.code !== 'EEXIST') {
|
|
274
|
+
throw error;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Recover from stale lock files left by crashed processes.
|
|
278
|
+
try {
|
|
279
|
+
const stats = await fs.promises.stat(CONFIG_LOCK_PATH);
|
|
280
|
+
if (Date.now() - stats.mtimeMs > CONFIG_LOCK_STALE_MS) {
|
|
281
|
+
await fs.promises.unlink(CONFIG_LOCK_PATH);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
} catch (_) {
|
|
285
|
+
// Lock may have been released between exists check and stat/unlink.
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (Date.now() - start >= timeoutMs) {
|
|
289
|
+
throw new Error(`Timed out waiting for config lock after ${timeoutMs}ms`);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
await sleep(CONFIG_LOCK_RETRY_MS);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return async function releaseConfigLock() {
|
|
297
|
+
try {
|
|
298
|
+
if (lockHandle) {
|
|
299
|
+
await lockHandle.close();
|
|
300
|
+
}
|
|
301
|
+
} catch (_) {
|
|
302
|
+
// Best-effort close only.
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
await fs.promises.unlink(CONFIG_LOCK_PATH);
|
|
306
|
+
} catch (_) {
|
|
307
|
+
// Best-effort cleanup only.
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function isAutosaveDisabled() {
|
|
313
|
+
const flag = String(process.env.I18NTK_DISABLE_AUTOSAVE || '').trim().toLowerCase();
|
|
314
|
+
return flag === '1' || flag === 'true' || flag === 'yes';
|
|
315
|
+
}
|
|
251
316
|
|
|
252
317
|
function clone(obj) {
|
|
253
318
|
return JSON.parse(JSON.stringify(obj));
|
|
@@ -424,28 +489,71 @@ function loadConfig() {
|
|
|
424
489
|
|
|
425
490
|
async function saveConfig(cfg = currentConfig) {
|
|
426
491
|
if (!cfg || typeof cfg !== 'object') return;
|
|
427
|
-
|
|
428
|
-
try {
|
|
429
|
-
// Ensure settings directory exists
|
|
430
|
-
if (!SecurityUtils.safeExistsSync(PROJECT_SETTINGS_DIR)) {
|
|
431
|
-
fs.mkdirSync(PROJECT_SETTINGS_DIR, { recursive: true });
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
const serialized = JSON.stringify(cfg, null, 2);
|
|
435
|
-
if (typeof serialized !== 'string' || serialized.length === 0) {
|
|
436
|
-
throw new Error('Cannot save empty configuration payload');
|
|
437
|
-
}
|
|
438
492
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
await fs.promises.writeFile(tempPath, serialized, 'utf8');
|
|
442
|
-
await fs.promises.rename(tempPath, PROJECT_CONFIG_PATH);
|
|
493
|
+
// Runtime/server safety valve: allow disabling disk writes entirely.
|
|
494
|
+
if (isAutosaveDisabled()) {
|
|
443
495
|
currentConfig = cfg;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
496
|
+
if (!autosaveDisabledWarned) {
|
|
497
|
+
autosaveDisabledWarned = true;
|
|
498
|
+
console.warn('[i18ntk] Autosave disabled by I18NTK_DISABLE_AUTOSAVE. Keeping configuration in memory only.');
|
|
499
|
+
}
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
configSaveQueue = configSaveQueue.then(async () => {
|
|
504
|
+
let tempPath = null;
|
|
505
|
+
let releaseLock = null;
|
|
506
|
+
try {
|
|
507
|
+
// Ensure settings directory exists before any lock/file operations.
|
|
508
|
+
await fs.promises.mkdir(PROJECT_SETTINGS_DIR, { recursive: true });
|
|
509
|
+
|
|
510
|
+
releaseLock = await acquireConfigLock();
|
|
511
|
+
|
|
512
|
+
const serialized = JSON.stringify(cfg, null, 2);
|
|
513
|
+
if (typeof serialized !== 'string' || serialized.length === 0) {
|
|
514
|
+
throw new Error('Cannot save empty configuration payload');
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Use a unique temp file to avoid concurrent writer races.
|
|
518
|
+
const nonce = `${process.pid}.${Date.now()}.${crypto.randomUUID()}`;
|
|
519
|
+
tempPath = `${PROJECT_CONFIG_PATH}.${nonce}.tmp`;
|
|
520
|
+
await fs.promises.writeFile(tempPath, serialized, 'utf8');
|
|
521
|
+
|
|
522
|
+
try {
|
|
523
|
+
await fs.promises.rename(tempPath, PROJECT_CONFIG_PATH);
|
|
524
|
+
} catch (renameError) {
|
|
525
|
+
// If destination dir disappeared between checks, recreate and retry once.
|
|
526
|
+
if (renameError && renameError.code === 'ENOENT') {
|
|
527
|
+
await fs.promises.mkdir(PROJECT_SETTINGS_DIR, { recursive: true });
|
|
528
|
+
await fs.promises.rename(tempPath, PROJECT_CONFIG_PATH);
|
|
529
|
+
} else {
|
|
530
|
+
throw renameError;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
currentConfig = cfg;
|
|
535
|
+
return true;
|
|
536
|
+
} catch (error) {
|
|
537
|
+
console.error('[i18ntk] Error saving configuration:', error.message);
|
|
538
|
+
return false;
|
|
539
|
+
} finally {
|
|
540
|
+
if (releaseLock) {
|
|
541
|
+
await releaseLock();
|
|
542
|
+
}
|
|
543
|
+
if (tempPath) {
|
|
544
|
+
try {
|
|
545
|
+
if (SecurityUtils.safeExistsSync(tempPath, path.dirname(tempPath))) {
|
|
546
|
+
fs.unlinkSync(tempPath);
|
|
547
|
+
}
|
|
548
|
+
} catch (_) {
|
|
549
|
+
// Best-effort temp cleanup only.
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
return configSaveQueue;
|
|
556
|
+
}
|
|
449
557
|
|
|
450
558
|
function getConfig() {
|
|
451
559
|
// Check for recursion
|
|
@@ -486,7 +594,9 @@ function getConfig() {
|
|
|
486
594
|
throw new Error('Invalid legacy configuration JSON');
|
|
487
595
|
}
|
|
488
596
|
const migratedConfig = { ...DEFAULT_CONFIG, ...legacyConfig };
|
|
489
|
-
saveConfig(migratedConfig)
|
|
597
|
+
saveConfig(migratedConfig).catch((err) => {
|
|
598
|
+
console.warn('[i18ntk] Warning: failed to persist migrated configuration:', err.message);
|
|
599
|
+
});
|
|
490
600
|
currentConfig = migratedConfig;
|
|
491
601
|
|
|
492
602
|
// Clean up legacy config
|
|
@@ -504,7 +614,9 @@ function getConfig() {
|
|
|
504
614
|
|
|
505
615
|
// Use package defaults for new installation
|
|
506
616
|
console.log('📦 Initializing with default configuration...');
|
|
507
|
-
saveConfig(DEFAULT_CONFIG)
|
|
617
|
+
saveConfig(DEFAULT_CONFIG).catch((err) => {
|
|
618
|
+
console.warn('[i18ntk] Warning: failed to persist default configuration:', err.message);
|
|
619
|
+
});
|
|
508
620
|
currentConfig = DEFAULT_CONFIG;
|
|
509
621
|
return resolvePaths(DEFAULT_CONFIG);
|
|
510
622
|
|