gtx-cli 2.3.7 → 2.3.9-alpha.0
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/api/sendFiles.js +5 -6
- package/dist/cli/flags.js +4 -3
- 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/api/sendFiles.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { createSpinner,
|
|
2
|
+
import { createSpinner, logErrorAndExit, logMessage, logSuccess, } from '../console/logging.js';
|
|
3
3
|
import { gt } from '../utils/gt.js';
|
|
4
4
|
import { TEMPLATE_FILE_NAME } from '../cli/commands/stage.js';
|
|
5
5
|
/**
|
|
@@ -29,7 +29,7 @@ export async function sendFiles(files, options, settings) {
|
|
|
29
29
|
const sourceLocale = settings.defaultLocale;
|
|
30
30
|
if (!sourceLocale) {
|
|
31
31
|
uploadSpinner.stop(chalk.red('Missing default source locale'));
|
|
32
|
-
|
|
32
|
+
logErrorAndExit('sendFiles: settings.defaultLocale is required to upload source files');
|
|
33
33
|
}
|
|
34
34
|
// Convert FileToTranslate[] -> { source: FileUpload }[]
|
|
35
35
|
const uploads = files.map(({ content, fileName, fileFormat, dataFormat }) => ({
|
|
@@ -105,11 +105,10 @@ export async function sendFiles(files, options, settings) {
|
|
|
105
105
|
logSuccess(message);
|
|
106
106
|
return { data, locales, translations };
|
|
107
107
|
}
|
|
108
|
-
catch
|
|
108
|
+
catch {
|
|
109
109
|
if (currentSpinner) {
|
|
110
|
-
currentSpinner.stop(
|
|
110
|
+
currentSpinner.stop();
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
throw error;
|
|
112
|
+
logErrorAndExit('Failed to send files for translation');
|
|
114
113
|
}
|
|
115
114
|
}
|
package/dist/cli/flags.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import findFilepath from '../fs/findFilepath.js';
|
|
2
|
+
import { logErrorAndExit } from '../console/logging.js';
|
|
2
3
|
const DEFAULT_TIMEOUT = 600;
|
|
3
4
|
export function attachTranslateFlags(command) {
|
|
4
5
|
command
|
|
@@ -12,10 +13,10 @@ export function attachTranslateFlags(command) {
|
|
|
12
13
|
.option('--timeout <seconds>', 'Translation wait timeout in seconds', (value) => {
|
|
13
14
|
const parsedValue = parseInt(value, 10);
|
|
14
15
|
if (isNaN(parsedValue)) {
|
|
15
|
-
|
|
16
|
+
logErrorAndExit('Not a number.');
|
|
16
17
|
}
|
|
17
18
|
if (parsedValue < 0) {
|
|
18
|
-
|
|
19
|
+
logErrorAndExit('Timeout must be a positive number.');
|
|
19
20
|
}
|
|
20
21
|
return parsedValue;
|
|
21
22
|
}, DEFAULT_TIMEOUT)
|
|
@@ -25,7 +26,7 @@ export function attachTranslateFlags(command) {
|
|
|
25
26
|
.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
27
|
.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
28
|
.option('--force', 'Force a retranslation, invalidating all existing cached translations if they exist.', false)
|
|
28
|
-
.option('--experimental-clear-locale-
|
|
29
|
+
.option('--experimental-clear-locale-dirs', 'Clear locale directories before downloading new translations', false);
|
|
29
30
|
return command;
|
|
30
31
|
}
|
|
31
32
|
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';
|