gt 2.14.29 → 2.14.30
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.14.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1304](https://github.com/generaltranslation/gt/pull/1304) [`c15ecf5`](https://github.com/generaltranslation/gt/commit/c15ecf581821a2feac72f53c5470b5b9b163564a) Thanks [@moss-bryophyta](https://github.com/moss-bryophyta)! - Sort JSON keys when outputting translation files for deterministic output
|
|
8
|
+
|
|
3
9
|
## 2.14.29
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -16,6 +16,10 @@ import stringify from 'fast-json-stable-stringify';
|
|
|
16
16
|
import { SUPPORTED_FILE_EXTENSIONS } from '../formats/files/supportedFiles.js';
|
|
17
17
|
import { hasNonIdentityFileFormatTransformForType } from '../formats/files/transformFormat.js';
|
|
18
18
|
import { getRelative } from '../fs/findFilepath.js';
|
|
19
|
+
function sortJsonString(data) {
|
|
20
|
+
const sortedData = stringify(JSON.parse(data));
|
|
21
|
+
return JSON.stringify(JSON.parse(sortedData), null, 2);
|
|
22
|
+
}
|
|
19
23
|
/**
|
|
20
24
|
* Merges translated content with the current source file for schema-based formats.
|
|
21
25
|
*/
|
|
@@ -160,8 +164,17 @@ export async function downloadFileBatch(fileTracker, files, options, forceDownlo
|
|
|
160
164
|
: null);
|
|
161
165
|
if (extracted) {
|
|
162
166
|
const remerged = mergeWithSource(extracted, locale, inputPath, options);
|
|
163
|
-
|
|
164
|
-
|
|
167
|
+
let remergedData = remerged;
|
|
168
|
+
if (outputPath.endsWith('.json')) {
|
|
169
|
+
try {
|
|
170
|
+
remergedData = sortJsonString(remergedData);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// Fall through with unsorted content
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (remergedData !== existingContent) {
|
|
177
|
+
await fs.promises.writeFile(outputPath, remergedData);
|
|
165
178
|
}
|
|
166
179
|
// Track for postprocessing (e.g. openapi path localization)
|
|
167
180
|
// even when the API download was skipped
|
|
@@ -175,16 +188,13 @@ export async function downloadFileBatch(fileTracker, files, options, forceDownlo
|
|
|
175
188
|
continue;
|
|
176
189
|
}
|
|
177
190
|
let data = mergeWithSource(file.data, locale, inputPath, options);
|
|
178
|
-
//
|
|
179
|
-
if (file.fileFormat === 'GTJSON') {
|
|
191
|
+
// Stable sort JSON keys for deterministic output
|
|
192
|
+
if (file.fileFormat === 'GTJSON' || outputPath.endsWith('.json')) {
|
|
180
193
|
try {
|
|
181
|
-
|
|
182
|
-
const sortedData = stringify(jsonData); // stably sort with fast-json-stable-stringify
|
|
183
|
-
const sortedJsonData = JSON.parse(sortedData);
|
|
184
|
-
data = JSON.stringify(sortedJsonData, null, 2); // format the data
|
|
194
|
+
data = sortJsonString(data);
|
|
185
195
|
}
|
|
186
196
|
catch (error) {
|
|
187
|
-
logger.warn(`Failed to sort
|
|
197
|
+
logger.warn(`Failed to sort JSON file: ${file.id}: ` + error);
|
|
188
198
|
}
|
|
189
199
|
}
|
|
190
200
|
// Write the file to disk
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "2.14.
|
|
1
|
+
export declare const PACKAGE_VERSION = "2.14.30";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated. Do not edit manually.
|
|
2
|
-
export const PACKAGE_VERSION = '2.14.
|
|
2
|
+
export const PACKAGE_VERSION = '2.14.30';
|