gtx-cli 2.4.13 → 2.4.15
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 +13 -0
- package/dist/formats/files/translate.js +25 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.4.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#792](https://github.com/generaltranslation/gt/pull/792) [`b6d6869`](https://github.com/generaltranslation/gt/commit/b6d686917316f6ed44130a54509459a7f9ee35fa) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Skipping over JSON and YAML files with failing parse to avoid crashing
|
|
8
|
+
|
|
9
|
+
## 2.4.14
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`3da05a1`](https://github.com/generaltranslation/gt/commit/3da05a12a37a62ace3c7e321aa2fed5a4af52ad9)]:
|
|
14
|
+
- generaltranslation@7.9.1
|
|
15
|
+
|
|
3
16
|
## 2.4.13
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -4,6 +4,7 @@ import { SUPPORTED_FILE_EXTENSIONS } from './supportedFiles.js';
|
|
|
4
4
|
import sanitizeFileContent from '../../utils/sanitizeFileContent.js';
|
|
5
5
|
import { parseJson } from '../json/parseJson.js';
|
|
6
6
|
import parseYaml from '../yaml/parseYaml.js';
|
|
7
|
+
import YAML from 'yaml';
|
|
7
8
|
import { determineLibrary } from '../../fs/determineFramework.js';
|
|
8
9
|
import { isValidMdx } from '../../utils/validateMdx.js';
|
|
9
10
|
export const SUPPORTED_DATA_FORMATS = ['JSX', 'ICU', 'I18NEXT'];
|
|
@@ -39,6 +40,14 @@ export async function aggregateFiles(settings) {
|
|
|
39
40
|
.map((filePath) => {
|
|
40
41
|
const content = readFile(filePath);
|
|
41
42
|
const relativePath = getRelative(filePath);
|
|
43
|
+
// Pre-validate JSON parseability
|
|
44
|
+
try {
|
|
45
|
+
JSON.parse(content);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
logWarning(`Skipping ${relativePath}: JSON file is not parsable`);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
42
51
|
const parsedJson = parseJson(content, filePath, settings.options || {}, settings.defaultLocale);
|
|
43
52
|
return {
|
|
44
53
|
content: parsedJson,
|
|
@@ -48,8 +57,10 @@ export async function aggregateFiles(settings) {
|
|
|
48
57
|
};
|
|
49
58
|
})
|
|
50
59
|
.filter((file) => {
|
|
51
|
-
if (!file
|
|
52
|
-
|
|
60
|
+
if (!file)
|
|
61
|
+
return false;
|
|
62
|
+
if (typeof file.content !== 'string' || !file.content.trim()) {
|
|
63
|
+
logWarning(`Skipping ${file.fileName}: JSON file is empty`);
|
|
53
64
|
return false;
|
|
54
65
|
}
|
|
55
66
|
return true;
|
|
@@ -62,6 +73,14 @@ export async function aggregateFiles(settings) {
|
|
|
62
73
|
.map((filePath) => {
|
|
63
74
|
const content = readFile(filePath);
|
|
64
75
|
const relativePath = getRelative(filePath);
|
|
76
|
+
// Pre-validate YAML parseability
|
|
77
|
+
try {
|
|
78
|
+
YAML.parse(content);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
logWarning(`Skipping ${relativePath}: YAML file is not parsable`);
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
65
84
|
const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, settings.options || {});
|
|
66
85
|
return {
|
|
67
86
|
content: parsedYaml,
|
|
@@ -70,8 +89,10 @@ export async function aggregateFiles(settings) {
|
|
|
70
89
|
};
|
|
71
90
|
})
|
|
72
91
|
.filter((file) => {
|
|
73
|
-
if (!file
|
|
74
|
-
|
|
92
|
+
if (!file)
|
|
93
|
+
return false;
|
|
94
|
+
if (typeof file.content !== 'string' || !file.content.trim()) {
|
|
95
|
+
logWarning(`Skipping ${file.fileName}: YAML file is empty`);
|
|
75
96
|
return false;
|
|
76
97
|
}
|
|
77
98
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtx-cli",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.15",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"unified": "^11.0.5",
|
|
95
95
|
"unist-util-visit": "^5.0.0",
|
|
96
96
|
"yaml": "^2.8.0",
|
|
97
|
-
"generaltranslation": "7.9.
|
|
97
|
+
"generaltranslation": "7.9.1"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@babel/types": "^7.28.4",
|