gtx-cli 2.4.4 → 2.4.5
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
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#759](https://github.com/generaltranslation/gt/pull/759) [`cf04026`](https://github.com/generaltranslation/gt/commit/cf04026df7072af60999f281ba342a1baa58f7ff) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Migrating downloaded-versions.json to gt-lock.json, make .gt and .locadex interchangable
|
|
8
|
+
|
|
3
9
|
## 2.4.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli/flags.js
CHANGED
|
@@ -26,7 +26,7 @@ export function attachTranslateFlags(command) {
|
|
|
26
26
|
.option('--experimental-flatten-json-files', 'Triggering this will flatten the json files into a single file. This is useful for projects that have a lot of json files.', false)
|
|
27
27
|
.option('--experimental-localize-static-imports', 'Triggering this will run a script after the cli tool that localizes all static imports in content files. Currently only supported for md and mdx files.', false)
|
|
28
28
|
.option('--force', 'Force a retranslation, invalidating all existing cached translations if they exist.', false)
|
|
29
|
-
.option('--force-download', 'Force download and overwrite local files, bypassing
|
|
29
|
+
.option('--force-download', 'Force download and overwrite local files, bypassing gt-lock.json checks.', false)
|
|
30
30
|
.option('--experimental-clear-locale-dirs', 'Clear locale directories before downloading new translations', false);
|
|
31
31
|
return command;
|
|
32
32
|
}
|
|
@@ -15,6 +15,14 @@ export function resolveConfig(cwd) {
|
|
|
15
15
|
config: loadConfig(path.join(cwd, 'src/gt.config.json')),
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
// Support config under .gt for parity with .locadex
|
|
19
|
+
if (fs.existsSync(path.join(cwd, '.gt/gt.config.json'))) {
|
|
20
|
+
return {
|
|
21
|
+
path: path.join(cwd, '.gt/gt.config.json'),
|
|
22
|
+
config: loadConfig(path.join(cwd, '.gt/gt.config.json')),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Backward compatibility: support legacy .locadex directory
|
|
18
26
|
if (fs.existsSync(path.join(cwd, '.locadex/gt.config.json'))) {
|
|
19
27
|
return {
|
|
20
28
|
path: path.join(cwd, '.locadex/gt.config.json'),
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { logError } from '../../console/logging.js';
|
|
4
|
-
|
|
4
|
+
// New lock file name, use old name for deletion of legacy lock file
|
|
5
|
+
const GT_LOCK_FILE = 'gt-lock.json';
|
|
6
|
+
const LEGACY_DOWNLOADED_VERSIONS_FILE = 'downloaded-versions.json';
|
|
5
7
|
export function getDownloadedVersions(configDirectory) {
|
|
6
8
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
// Clean up legacy lock files inside the config directory
|
|
10
|
+
const rootPath = path.join(process.cwd(), GT_LOCK_FILE);
|
|
11
|
+
const legacyPath = path.join(configDirectory, LEGACY_DOWNLOADED_VERSIONS_FILE);
|
|
12
|
+
try {
|
|
13
|
+
if (fs.existsSync(legacyPath)) {
|
|
14
|
+
fs.unlinkSync(legacyPath);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch { }
|
|
18
|
+
const filepath = fs.existsSync(rootPath) ? rootPath : null;
|
|
19
|
+
if (!filepath)
|
|
9
20
|
return { version: 1, entries: {} };
|
|
10
21
|
const raw = JSON.parse(fs.readFileSync(filepath, 'utf8'));
|
|
11
22
|
if (raw && typeof raw === 'object' && raw.version && raw.entries) {
|
|
@@ -20,11 +31,12 @@ export function getDownloadedVersions(configDirectory) {
|
|
|
20
31
|
}
|
|
21
32
|
export function saveDownloadedVersions(configDirectory, lock) {
|
|
22
33
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
// Write the lock file to the repo root
|
|
35
|
+
const filepath = path.join(process.cwd(), GT_LOCK_FILE);
|
|
36
|
+
fs.mkdirSync(path.dirname(filepath), { recursive: true });
|
|
25
37
|
fs.writeFileSync(filepath, JSON.stringify(lock, null, 2));
|
|
26
38
|
}
|
|
27
39
|
catch (error) {
|
|
28
|
-
logError(`An error occurred while updating ${
|
|
40
|
+
logError(`An error occurred while updating ${GT_LOCK_FILE}: ${error}`);
|
|
29
41
|
}
|
|
30
42
|
}
|