gtx-cli 2.0.20 → 2.0.22
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 +12 -0
- package/dist/api/downloadFile.js +5 -5
- package/dist/cli/base.js +1 -0
- package/dist/formats/files/translate.js +2 -2
- package/dist/formats/files/upload.js +2 -2
- package/dist/formats/yaml/parseYaml.d.ts +4 -1
- package/dist/formats/yaml/parseYaml.js +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.0.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#527](https://github.com/generaltranslation/gt/pull/527) [`d209aa9`](https://github.com/generaltranslation/gt/commit/d209aa99dbae8627ea85b240b60d4bbb5a53dbd6) Thanks [@brian-lou](https://github.com/brian-lou)! - Bump form-data version to address CVE-2025-7783
|
|
8
|
+
|
|
9
|
+
## 2.0.21
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#524](https://github.com/generaltranslation/gt/pull/524) [`39b36e5`](https://github.com/generaltranslation/gt/commit/39b36e56f50fff663826c66022d798147a622898) Thanks [@brian-lou](https://github.com/brian-lou)! - Add support for translating YAML files via the General Translation API
|
|
14
|
+
|
|
3
15
|
## 2.0.20
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/api/downloadFile.js
CHANGED
|
@@ -27,9 +27,9 @@ export async function downloadFile(translationId, outputPath, inputPath, locale,
|
|
|
27
27
|
}
|
|
28
28
|
let data = new TextDecoder().decode(fileData);
|
|
29
29
|
if (options.options?.jsonSchema && locale) {
|
|
30
|
-
const jsonSchema = validateJsonSchema(options.options,
|
|
30
|
+
const jsonSchema = validateJsonSchema(options.options, inputPath);
|
|
31
31
|
if (jsonSchema) {
|
|
32
|
-
const originalContent = fs.readFileSync(
|
|
32
|
+
const originalContent = fs.readFileSync(inputPath, 'utf8');
|
|
33
33
|
if (originalContent) {
|
|
34
34
|
data = mergeJson(originalContent, inputPath, options.options, [
|
|
35
35
|
{
|
|
@@ -41,11 +41,11 @@ export async function downloadFile(translationId, outputPath, inputPath, locale,
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
if (options.options?.yamlSchema && locale) {
|
|
44
|
-
const yamlSchema = validateYamlSchema(options.options,
|
|
44
|
+
const yamlSchema = validateYamlSchema(options.options, inputPath);
|
|
45
45
|
if (yamlSchema) {
|
|
46
|
-
const originalContent = fs.readFileSync(
|
|
46
|
+
const originalContent = fs.readFileSync(inputPath, 'utf8');
|
|
47
47
|
if (originalContent) {
|
|
48
|
-
data = mergeYaml(originalContent,
|
|
48
|
+
data = mergeYaml(originalContent, inputPath, options.options, [
|
|
49
49
|
{
|
|
50
50
|
translatedContent: data,
|
|
51
51
|
targetLocale: locale,
|
package/dist/cli/base.js
CHANGED
|
@@ -284,6 +284,7 @@ See the docs for more information: https://generaltranslation.com/docs/react/tut
|
|
|
284
284
|
{ value: 'mdx', label: FILE_EXT_TO_EXT_LABEL.mdx },
|
|
285
285
|
{ value: 'ts', label: FILE_EXT_TO_EXT_LABEL.ts },
|
|
286
286
|
{ value: 'js', label: FILE_EXT_TO_EXT_LABEL.js },
|
|
287
|
+
{ value: 'yaml', label: FILE_EXT_TO_EXT_LABEL.yaml },
|
|
287
288
|
],
|
|
288
289
|
required: !isUsingGT,
|
|
289
290
|
});
|
|
@@ -50,12 +50,12 @@ export async function translateFiles(filePaths, placeholderPaths, transformPaths
|
|
|
50
50
|
}
|
|
51
51
|
const yamlFiles = filePaths.yaml.map((filePath) => {
|
|
52
52
|
const content = readFile(filePath);
|
|
53
|
-
const parsedYaml = parseYaml(content, filePath, additionalOptions);
|
|
53
|
+
const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, additionalOptions);
|
|
54
54
|
const relativePath = getRelative(filePath);
|
|
55
55
|
return {
|
|
56
56
|
content: parsedYaml,
|
|
57
57
|
fileName: relativePath,
|
|
58
|
-
fileFormat
|
|
58
|
+
fileFormat,
|
|
59
59
|
dataFormat,
|
|
60
60
|
};
|
|
61
61
|
});
|
|
@@ -51,12 +51,12 @@ export async function upload(filePaths, placeholderPaths, transformPaths, dataFo
|
|
|
51
51
|
}
|
|
52
52
|
const yamlFiles = filePaths.yaml.map((filePath) => {
|
|
53
53
|
const content = readFile(filePath);
|
|
54
|
-
const parsedYaml = parseYaml(content, filePath, additionalOptions);
|
|
54
|
+
const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, additionalOptions);
|
|
55
55
|
const relativePath = getRelative(filePath);
|
|
56
56
|
return {
|
|
57
57
|
content: parsedYaml,
|
|
58
58
|
fileName: relativePath,
|
|
59
|
-
fileFormat
|
|
59
|
+
fileFormat,
|
|
60
60
|
dataFormat,
|
|
61
61
|
locale: options.defaultLocale,
|
|
62
62
|
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { AdditionalOptions } from '../../types/index.js';
|
|
2
|
-
export default function parseYaml(content: string, filePath: string, options: AdditionalOptions):
|
|
2
|
+
export default function parseYaml(content: string, filePath: string, options: AdditionalOptions): {
|
|
3
|
+
content: string;
|
|
4
|
+
fileFormat: 'JSON' | 'YAML';
|
|
5
|
+
};
|
|
@@ -5,7 +5,7 @@ import { flattenJsonWithStringFilter } from '../json/flattenJson.js';
|
|
|
5
5
|
export default function parseYaml(content, filePath, options) {
|
|
6
6
|
const yamlSchema = validateYamlSchema(options, filePath);
|
|
7
7
|
if (!yamlSchema) {
|
|
8
|
-
return content;
|
|
8
|
+
return { content, fileFormat: 'YAML' };
|
|
9
9
|
}
|
|
10
10
|
let yaml;
|
|
11
11
|
try {
|
|
@@ -17,7 +17,7 @@ export default function parseYaml(content, filePath, options) {
|
|
|
17
17
|
}
|
|
18
18
|
if (yamlSchema.include) {
|
|
19
19
|
const flattenedYaml = flattenJsonWithStringFilter(yaml, yamlSchema.include);
|
|
20
|
-
return JSON.stringify(flattenedYaml);
|
|
20
|
+
return { content: JSON.stringify(flattenedYaml), fileFormat: 'JSON' };
|
|
21
21
|
}
|
|
22
|
-
return content;
|
|
22
|
+
return { content, fileFormat: 'YAML' };
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtx-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.22",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"dotenv": "^16.4.5",
|
|
87
87
|
"esbuild": "^0.25.4",
|
|
88
88
|
"fast-glob": "^3.3.3",
|
|
89
|
-
"form-data": "^4.0.
|
|
89
|
+
"form-data": "^4.0.4",
|
|
90
90
|
"generaltranslation": "^7.1.4",
|
|
91
91
|
"json-pointer": "^0.6.2",
|
|
92
92
|
"jsonpath-plus": "^10.3.0",
|