gtx-cli 2.3.7 → 2.3.8
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 +6 -0
- package/dist/api/checkFileTranslations.js +3 -3
- package/dist/cli/flags.js +1 -1
- package/dist/config/generateSettings.js +4 -4
- package/dist/fs/{clearLocaleFolders.d.ts → clearLocaleDirs.d.ts} +1 -1
- package/dist/fs/{clearLocaleFolders.js → clearLocaleDirs.js} +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.3.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#713](https://github.com/generaltranslation/gt/pull/713) [`b8feb26`](https://github.com/generaltranslation/gt/commit/b8feb2638613f54b76b5f3768edc6039db512c53) Thanks [@SamEggert](https://github.com/SamEggert)! - rename clearLocaleFolders to clearLocaleDirs
|
|
8
|
+
|
|
3
9
|
## 2.3.7
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ import { getLocaleProperties } from 'generaltranslation';
|
|
|
4
4
|
import { downloadFileBatch } from './downloadFileBatch.js';
|
|
5
5
|
import { gt } from '../utils/gt.js';
|
|
6
6
|
import { TEMPLATE_FILE_NAME } from '../cli/commands/stage.js';
|
|
7
|
-
import {
|
|
7
|
+
import { clearLocaleDirs } from '../fs/clearLocaleDirs.js';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
/**
|
|
10
10
|
* Checks the status of translations for a given version ID
|
|
@@ -27,7 +27,7 @@ export async function checkFileTranslations(data, locales, timeoutDuration, reso
|
|
|
27
27
|
// Initialize the query data
|
|
28
28
|
const fileQueryData = prepareFileQueryData(data, locales);
|
|
29
29
|
// Clear translated files before any downloads (if enabled)
|
|
30
|
-
if (options.options?.
|
|
30
|
+
if (options.options?.experimentalClearLocaleDirs === true &&
|
|
31
31
|
fileQueryData.length > 0) {
|
|
32
32
|
const translatedFiles = new Set(fileQueryData
|
|
33
33
|
.map((file) => {
|
|
@@ -40,7 +40,7 @@ export async function checkFileTranslations(data, locales, timeoutDuration, reso
|
|
|
40
40
|
.filter((path) => path !== null));
|
|
41
41
|
// Derive cwd from config path
|
|
42
42
|
const cwd = path.dirname(options.config);
|
|
43
|
-
await
|
|
43
|
+
await clearLocaleDirs(translatedFiles, locales, options.options?.clearLocaleDirsExclude, cwd);
|
|
44
44
|
}
|
|
45
45
|
const downloadStatus = {
|
|
46
46
|
downloaded: new Set(),
|
package/dist/cli/flags.js
CHANGED
|
@@ -25,7 +25,7 @@ export function attachTranslateFlags(command) {
|
|
|
25
25
|
.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)
|
|
26
26
|
.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)
|
|
27
27
|
.option('--force', 'Force a retranslation, invalidating all existing cached translations if they exist.', false)
|
|
28
|
-
.option('--experimental-clear-locale-
|
|
28
|
+
.option('--experimental-clear-locale-dirs', 'Clear locale directories before downloading new translations', false);
|
|
29
29
|
return command;
|
|
30
30
|
}
|
|
31
31
|
export function attachAdditionalReactTranslateFlags(command) {
|
|
@@ -126,10 +126,10 @@ export async function generateSettings(options, cwd = process.cwd()) {
|
|
|
126
126
|
options.experimentalHideDefaultLocale,
|
|
127
127
|
experimentalFlattenJsonFiles: gtConfig.options?.experimentalFlattenJsonFiles ||
|
|
128
128
|
options.experimentalFlattenJsonFiles,
|
|
129
|
-
|
|
130
|
-
options.
|
|
131
|
-
|
|
132
|
-
options.
|
|
129
|
+
experimentalClearLocaleDirs: gtConfig.options?.experimentalClearLocaleDirs ||
|
|
130
|
+
options.experimentalClearLocaleDirs,
|
|
131
|
+
clearLocaleDirsExclude: gtConfig.options?.clearLocaleDirsExclude ||
|
|
132
|
+
options.clearLocaleDirsExclude,
|
|
133
133
|
};
|
|
134
134
|
// Add additional options if provided
|
|
135
135
|
if (mergedOptions.options) {
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param excludePatterns - Optional array of glob patterns to exclude from clearing (supports [locale] and [locales])
|
|
6
6
|
* @param cwd - Current working directory for resolving relative exclude patterns (defaults to process.cwd())
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function clearLocaleDirs(filePaths: Set<string>, locales: string[], excludePatterns?: string[], cwd?: string): Promise<void>;
|
|
@@ -54,7 +54,7 @@ async function getFilesToDelete(dirPath, excludePatterns, currentLocale, cwd) {
|
|
|
54
54
|
* @param excludePatterns - Optional array of glob patterns to exclude from clearing (supports [locale] and [locales])
|
|
55
55
|
* @param cwd - Current working directory for resolving relative exclude patterns (defaults to process.cwd())
|
|
56
56
|
*/
|
|
57
|
-
export async function
|
|
57
|
+
export async function clearLocaleDirs(filePaths, locales, excludePatterns, cwd = process.cwd()) {
|
|
58
58
|
// Extract locale directories
|
|
59
59
|
const localeDirs = extractLocaleDirectories(filePaths, locales);
|
|
60
60
|
for (const dir of localeDirs) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -143,8 +143,8 @@ export type AdditionalOptions = {
|
|
|
143
143
|
excludeStaticImports?: string[];
|
|
144
144
|
docsHideDefaultLocaleImport?: boolean;
|
|
145
145
|
copyFiles?: string[];
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
experimentalClearLocaleDirs?: boolean;
|
|
147
|
+
clearLocaleDirsExclude?: string[];
|
|
148
148
|
experimentalLocalizeStaticImports?: boolean;
|
|
149
149
|
experimentalLocalizeStaticUrls?: boolean;
|
|
150
150
|
experimentalAddHeaderAnchorIds?: 'mintlify';
|