gt 2.12.0 → 2.12.1
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 +10 -0
- package/dist/api/downloadFileBatch.js +1 -0
- package/dist/cli/commands/download.js +2 -2
- package/dist/cli/commands/stage.js +8 -6
- package/dist/fs/config/downloadedVersions.d.ts +19 -0
- package/dist/fs/config/downloadedVersions.js +34 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1140](https://github.com/generaltranslation/gt/pull/1140) [`46e089c`](https://github.com/generaltranslation/gt/commit/46e089c63725acc2c478a4c1965bebd6f2d2cc0e) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Adding staged status to `gt-lock.json`, adding `useLatestAvailableVersion` flag to core download
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`d688831`](https://github.com/generaltranslation/gt/commit/d688831d124f9719357100a93e5a7c37729e751e), [`46e089c`](https://github.com/generaltranslation/gt/commit/46e089c63725acc2c478a4c1965bebd6f2d2cc0e)]:
|
|
10
|
+
- generaltranslation@8.1.21
|
|
11
|
+
- @generaltranslation/python-extractor@0.2.1
|
|
12
|
+
|
|
3
13
|
## 2.12.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -151,6 +151,7 @@ export async function downloadFileBatch(fileTracker, files, options, forceDownlo
|
|
|
151
151
|
if (fileId && versionId && locale) {
|
|
152
152
|
const entry = findOrCreateEntry(entryMap, downloadedVersions.entries, fileId, versionId);
|
|
153
153
|
entry.fileName = inputPath;
|
|
154
|
+
entry.staged = false;
|
|
154
155
|
entry.translations[locale] = {
|
|
155
156
|
updatedAt: new Date().toISOString(),
|
|
156
157
|
fileName: outputPath,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { noVersionIdError, noFilesError } from '../../console/index.js';
|
|
2
2
|
import { createFileMapping } from '../../formats/files/fileMapping.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getStagedEntriesFromLockfile } from '../../fs/config/downloadedVersions.js';
|
|
4
4
|
import { runDownloadWorkflow, } from '../../workflows/download.js';
|
|
5
5
|
import { exitSync, logErrorAndExit } from '../../console/logging.js';
|
|
6
6
|
import { convertToFileTranslationData } from '../../formats/files/convertToFileTranslationData.js';
|
|
@@ -30,7 +30,7 @@ export async function handleDownload(options, settings, library) {
|
|
|
30
30
|
// Collect the hashes for all files we need to download
|
|
31
31
|
let fileVersionData;
|
|
32
32
|
if (settings.stageTranslations) {
|
|
33
|
-
fileVersionData =
|
|
33
|
+
fileVersionData = getStagedEntriesFromLockfile(settings);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
const { files } = await collectFiles(options, settings, library);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logger } from '../../console/logger.js';
|
|
2
2
|
import { exitSync, logCollectedFiles } from '../../console/logging.js';
|
|
3
3
|
import { runStageFilesWorkflow } from '../../workflows/stage.js';
|
|
4
|
-
import {
|
|
4
|
+
import { writeStagedEntries } from '../../fs/config/downloadedVersions.js';
|
|
5
5
|
import updateConfig from '../../fs/config/updateConfig.js';
|
|
6
6
|
import { TEMPLATE_FILE_ID } from '../../utils/constants.js';
|
|
7
7
|
import { collectFiles } from '../../formats/files/collectFiles.js';
|
|
@@ -29,12 +29,14 @@ export async function handleStage(options, settings, library, stage) {
|
|
|
29
29
|
jobData = enqueueResult;
|
|
30
30
|
branchData = branchDataResult;
|
|
31
31
|
fileVersionData = convertToFileTranslationData(allFiles);
|
|
32
|
-
//
|
|
32
|
+
// Write staged entries to the lockfile
|
|
33
33
|
if (stage) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const stagedFiles = Object.entries(fileVersionData).map(([fileId, data]) => ({
|
|
35
|
+
fileId,
|
|
36
|
+
versionId: data.versionId,
|
|
37
|
+
fileName: data.fileName,
|
|
38
|
+
}));
|
|
39
|
+
writeStagedEntries(settings, stagedFiles);
|
|
38
40
|
}
|
|
39
41
|
const templateData = allFiles.find((file) => file.fileId === TEMPLATE_FILE_ID);
|
|
40
42
|
if (templateData?.versionId) {
|
|
@@ -8,6 +8,7 @@ export type DownloadedVersionEntry = {
|
|
|
8
8
|
fileId: string;
|
|
9
9
|
versionId: string;
|
|
10
10
|
fileName?: string;
|
|
11
|
+
staged?: boolean;
|
|
11
12
|
translations: {
|
|
12
13
|
[locale: string]: DownloadedTranslation;
|
|
13
14
|
};
|
|
@@ -58,3 +59,21 @@ export declare function buildEntryMap(entries: DownloadedVersionEntry[]): EntryM
|
|
|
58
59
|
* If the fileId exists but versionId changed, replaces it in-place.
|
|
59
60
|
*/
|
|
60
61
|
export declare function findOrCreateEntry(entryMap: EntryMap, entries: DownloadedVersionEntry[], fileId: string, versionId: string): DownloadedVersionEntry;
|
|
62
|
+
/**
|
|
63
|
+
* Writes staged file entries into the lockfile.
|
|
64
|
+
* Each entry is marked with `staged: true` and empty translations.
|
|
65
|
+
*/
|
|
66
|
+
export declare function writeStagedEntries(settings: Settings, stagedFiles: {
|
|
67
|
+
fileId: string;
|
|
68
|
+
versionId: string;
|
|
69
|
+
fileName: string;
|
|
70
|
+
}[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Reads staged entries from the lockfile.
|
|
73
|
+
* Returns the same shape as FileTranslationData for compatibility
|
|
74
|
+
* with the download workflow.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getStagedEntriesFromLockfile(settings: Settings): Record<string, {
|
|
77
|
+
versionId: string;
|
|
78
|
+
fileName: string;
|
|
79
|
+
}>;
|
|
@@ -114,7 +114,8 @@ export function writeLockfile(data, originalV1) {
|
|
|
114
114
|
try {
|
|
115
115
|
const filepath = path.join(process.cwd(), GT_LOCK_FILE);
|
|
116
116
|
fs.mkdirSync(path.dirname(filepath), { recursive: true });
|
|
117
|
-
if
|
|
117
|
+
// V1 format can't represent the staged flag — upgrade to V2 if any entries are staged
|
|
118
|
+
if (originalV1 && !data.entries.some((e) => e.staged)) {
|
|
118
119
|
const mergedV1 = {
|
|
119
120
|
...originalV1,
|
|
120
121
|
entries: {
|
|
@@ -165,3 +166,35 @@ export function findOrCreateEntry(entryMap, entries, fileId, versionId) {
|
|
|
165
166
|
entryMap.set(fileId, entry);
|
|
166
167
|
return entry;
|
|
167
168
|
}
|
|
169
|
+
// ── Staging helpers ─────────────────────────────────────────────────
|
|
170
|
+
/**
|
|
171
|
+
* Writes staged file entries into the lockfile.
|
|
172
|
+
* Each entry is marked with `staged: true` and empty translations.
|
|
173
|
+
*/
|
|
174
|
+
export function writeStagedEntries(settings, stagedFiles) {
|
|
175
|
+
const { data, entryMap, originalV1 } = readLockfile(settings);
|
|
176
|
+
for (const file of stagedFiles) {
|
|
177
|
+
const entry = findOrCreateEntry(entryMap, data.entries, file.fileId, file.versionId);
|
|
178
|
+
entry.fileName = file.fileName;
|
|
179
|
+
entry.staged = true;
|
|
180
|
+
}
|
|
181
|
+
writeLockfile(data, originalV1);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Reads staged entries from the lockfile.
|
|
185
|
+
* Returns the same shape as FileTranslationData for compatibility
|
|
186
|
+
* with the download workflow.
|
|
187
|
+
*/
|
|
188
|
+
export function getStagedEntriesFromLockfile(settings) {
|
|
189
|
+
const { data } = readLockfile(settings);
|
|
190
|
+
const result = {};
|
|
191
|
+
for (const entry of data.entries) {
|
|
192
|
+
if (entry.staged && entry.fileName) {
|
|
193
|
+
result[entry.fileId] = {
|
|
194
|
+
versionId: entry.versionId,
|
|
195
|
+
fileName: entry.fileName,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "2.12.
|
|
1
|
+
export declare const PACKAGE_VERSION = "2.12.1";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated. Do not edit manually.
|
|
2
|
-
export const PACKAGE_VERSION = '2.12.
|
|
2
|
+
export const PACKAGE_VERSION = '2.12.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -110,8 +110,8 @@
|
|
|
110
110
|
"unified": "^11.0.5",
|
|
111
111
|
"unist-util-visit": "^5.0.0",
|
|
112
112
|
"yaml": "^2.8.0",
|
|
113
|
-
"@generaltranslation/python-extractor": "0.2.
|
|
114
|
-
"generaltranslation": "8.1.
|
|
113
|
+
"@generaltranslation/python-extractor": "0.2.1",
|
|
114
|
+
"generaltranslation": "8.1.21",
|
|
115
115
|
"gt-remark": "1.0.6"
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|