gtx-cli 1.2.25-alpha.10 → 1.2.25-alpha.12

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.
@@ -132,21 +132,21 @@ function generateStatusSuffixText(downloadStatus, fileQueryData) {
132
132
  // Add completed locales
133
133
  if (status.completed.size > 0) {
134
134
  const completedCodes = Array.from(status.completed)
135
- .map((locale) => generaltranslation_1.GT.getLocaleProperties(locale).code)
135
+ .map((locale) => (0, generaltranslation_1.getLocaleProperties)(locale).code)
136
136
  .join(', ');
137
137
  localeStatuses.push(chalk_1.default.green(`${completedCodes}`));
138
138
  }
139
139
  // Add failed locales
140
140
  if (status.failed.size > 0) {
141
141
  const failedCodes = Array.from(status.failed)
142
- .map((locale) => generaltranslation_1.GT.getLocaleProperties(locale).code)
142
+ .map((locale) => (0, generaltranslation_1.getLocaleProperties)(locale).code)
143
143
  .join(', ');
144
144
  localeStatuses.push(chalk_1.default.red(`${failedCodes}`));
145
145
  }
146
146
  // Add pending locales
147
147
  if (status.pending.size > 0) {
148
148
  const pendingCodes = Array.from(status.pending)
149
- .map((locale) => generaltranslation_1.GT.getLocaleProperties(locale).code)
149
+ .map((locale) => (0, generaltranslation_1.getLocaleProperties)(locale).code)
150
150
  .join(', ');
151
151
  localeStatuses.push(chalk_1.default.yellow(`${pendingCodes}`));
152
152
  }
@@ -1,17 +1,17 @@
1
1
  import { Settings } from '../types';
2
- import { FileExtension, Format } from '../types/data';
2
+ import { FileExtension, DataFormat } from '../types/data';
3
3
  /**
4
4
  * File object structure
5
5
  * @param content - The content of the file
6
6
  * @param fileName - The name of the file
7
7
  * @param fileExtension - The format of the file (JSON, MDX, MD, etc.)
8
- * @param format - The format of the data within the file
8
+ * @param dataFormat - The format of the data within the file
9
9
  */
10
10
  export interface FileToTranslate {
11
11
  content: string;
12
12
  fileName: string;
13
13
  fileExtension: FileExtension;
14
- format: Format;
14
+ dataFormat: DataFormat;
15
15
  }
16
16
  type ApiOptions = Settings & {
17
17
  publish: boolean;
@@ -26,7 +26,7 @@ async function sendFiles(files, options) {
26
26
  files.forEach((file, index) => {
27
27
  formData.append(`file${index}`, new Blob([file.content]), file.fileName);
28
28
  formData.append(`fileExtension${index}`, file.fileExtension);
29
- formData.append(`format${index}`, file.format); // Only used when translating JSON files
29
+ formData.append(`dataFormat${index}`, file.dataFormat); // Only used when translating JSON files
30
30
  formData.append(`fileName${index}`, file.fileName);
31
31
  });
32
32
  // Add number of files
@@ -1,8 +1,8 @@
1
1
  import { Settings, SupportedLibraries, Updates } from '../types';
2
- import { Format } from '../types/data';
2
+ import { DataFormat } from '../types/data';
3
3
  type ApiOptions = Settings & {
4
4
  timeout: string;
5
- format: Format;
5
+ dataFormat: DataFormat;
6
6
  description?: string;
7
7
  requireApproval?: boolean;
8
8
  };
@@ -15,7 +15,7 @@ const utils_1 = require("../config/utils");
15
15
  * @returns The versionId of the updated project
16
16
  */
17
17
  async function sendUpdates(updates, options, library) {
18
- const { apiKey, projectId, defaultLocale, format } = options;
18
+ const { apiKey, projectId, defaultLocale, dataFormat } = options;
19
19
  const globalMetadata = {
20
20
  ...(projectId && { projectId }),
21
21
  ...(defaultLocale && { sourceLocale: defaultLocale }),
@@ -27,7 +27,7 @@ async function sendUpdates(updates, options, library) {
27
27
  updates,
28
28
  ...(options.locales && { locales: options.locales }),
29
29
  metadata: globalMetadata,
30
- ...(format && { format }),
30
+ ...(dataFormat && { dataFormat }),
31
31
  ...(options.version && { versionId: options.version }),
32
32
  ...(options.description && { description: options.description }),
33
33
  ...(options.requireApproval && {
@@ -47,7 +47,7 @@ const waitForUpdates = async (apiKey, baseUrl, versionId, startTime, timeoutDura
47
47
  chalk_1.default.green(`[${availableLocales.length}/${locales.length}]`) +
48
48
  ` translations completed`,
49
49
  ...availableLocales.map((locale) => {
50
- const localeProperties = generaltranslation_1.GT.getLocaleProperties(locale);
50
+ const localeProperties = (0, generaltranslation_1.getLocaleProperties)(locale);
51
51
  return `Translation completed for ${chalk_1.default.green(localeProperties.name)} (${chalk_1.default.green(localeProperties.code)})`;
52
52
  }),
53
53
  ];
package/dist/cli/base.js CHANGED
@@ -187,21 +187,21 @@ See the docs for more information: https://generaltranslation.com/docs/react/tut
187
187
  });
188
188
  }
189
189
  async handleGenericTranslate(settings) {
190
- // format for JSONs
191
- let format;
190
+ // dataFormat for JSONs
191
+ let dataFormat;
192
192
  if (this.library === 'next-intl') {
193
- format = 'ICU';
193
+ dataFormat = 'ICU';
194
194
  }
195
195
  else if (this.library === 'i18next') {
196
196
  if (this.additionalModules.includes('i18next-icu')) {
197
- format = 'ICU';
197
+ dataFormat = 'ICU';
198
198
  }
199
199
  else {
200
- format = 'I18NEXT';
200
+ dataFormat = 'I18NEXT';
201
201
  }
202
202
  }
203
203
  else {
204
- format = 'JSX';
204
+ dataFormat = 'JSX';
205
205
  }
206
206
  if (!settings.files ||
207
207
  (Object.keys(settings.files.placeholderPaths).length === 1 &&
@@ -210,7 +210,7 @@ See the docs for more information: https://generaltranslation.com/docs/react/tut
210
210
  }
211
211
  const { resolvedPaths: sourceFiles, placeholderPaths, transformPaths, } = settings.files;
212
212
  // Process all file types at once with a single call
213
- await (0, translate_1.translateFiles)(sourceFiles, placeholderPaths, transformPaths, format, settings);
213
+ await (0, translate_1.translateFiles)(sourceFiles, placeholderPaths, transformPaths, dataFormat, settings);
214
214
  }
215
215
  async handleSetupReactCommand(options) {
216
216
  await (0, wizard_1.handleSetupReactCommand)(options);
@@ -6,18 +6,18 @@ const console_1 = require("../console");
6
6
  function validateSettings(settings) {
7
7
  // Validate locales
8
8
  for (const locale of settings.locales) {
9
- if (!generaltranslation_1.GT.isValidLocale(locale)) {
9
+ if (!(0, generaltranslation_1.isValidLocale)(locale)) {
10
10
  (0, console_1.logErrorAndExit)(`Provided locales: "${settings?.locales?.join()}", ${locale} is not a valid locale!`);
11
11
  }
12
12
  }
13
- if (settings.defaultLocale && !generaltranslation_1.GT.isValidLocale(settings.defaultLocale)) {
13
+ if (settings.defaultLocale && !(0, generaltranslation_1.isValidLocale)(settings.defaultLocale)) {
14
14
  (0, console_1.logErrorAndExit)(`defaultLocale: ${settings.defaultLocale} is not a valid locale!`);
15
15
  }
16
16
  // defaultLocale cannot be a superset of any other locale
17
17
  if (settings.defaultLocale &&
18
- settings.locales.some((locale) => generaltranslation_1.GT.isSupersetLocale(settings.defaultLocale, locale) &&
19
- !generaltranslation_1.GT.isSupersetLocale(locale, settings.defaultLocale))) {
20
- const locale = settings.locales.find((locale) => generaltranslation_1.GT.isSupersetLocale(settings.defaultLocale, locale));
18
+ settings.locales.some((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale) &&
19
+ !(0, generaltranslation_1.isSupersetLocale)(locale, settings.defaultLocale))) {
20
+ const locale = settings.locales.find((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale));
21
21
  (0, console_1.logErrorAndExit)(`defaultLocale: ${settings.defaultLocale} is a superset of another locale (${locale})! Please change the defaultLocale to a more specific locale.`);
22
22
  }
23
23
  }
@@ -1,5 +1,5 @@
1
- import { Format } from '../../types/data';
1
+ import { DataFormat } from '../../types/data';
2
2
  /**
3
3
  * Saves translated MDX/MD file content to the appropriate location
4
4
  */
5
- export declare function saveTranslatedFile(translatedContent: string, outputDir: string, fileName: string, format: Format, locales: string[]): Promise<void>;
5
+ export declare function saveTranslatedFile(translatedContent: string, outputDir: string, fileName: string, dataFormat: DataFormat, locales: string[]): Promise<void>;
@@ -10,7 +10,7 @@ const console_1 = require("../../console");
10
10
  /**
11
11
  * Saves translated MDX/MD file content to the appropriate location
12
12
  */
13
- async function saveTranslatedFile(translatedContent, outputDir, fileName, format, locales) {
13
+ async function saveTranslatedFile(translatedContent, outputDir, fileName, dataFormat, locales) {
14
14
  // Create locale-specific directories if they don't exist
15
15
  for (const locale of locales) {
16
16
  const localeDir = node_path_1.default.join(outputDir, locale);
@@ -18,6 +18,6 @@ async function saveTranslatedFile(translatedContent, outputDir, fileName, format
18
18
  // Save the translated file with the appropriate extension
19
19
  const outputPath = node_path_1.default.join(localeDir, fileName);
20
20
  await promises_1.default.writeFile(outputPath, translatedContent);
21
- (0, console_1.logSuccess)(`Saved translated ${format} file to: ${outputPath}`);
21
+ (0, console_1.logSuccess)(`Saved translated ${dataFormat} file to: ${outputPath}`);
22
22
  }
23
23
  }
@@ -1,13 +1,13 @@
1
1
  import { ResolvedFiles, Settings, TransformFiles } from '../../types';
2
- import { Format } from '../../types/data';
2
+ import { DataFormat } from '../../types/data';
3
3
  import { TranslateOptions } from '../../cli/base';
4
4
  /**
5
5
  * Sends multiple files to the API for translation
6
6
  * @param filePaths - Resolved file paths for different file types
7
7
  * @param placeholderPaths - Placeholder paths for translated files
8
8
  * @param transformPaths - Transform paths for file naming
9
- * @param format - Format of the data within the files
9
+ * @param dataFormat - Format of the data within the files
10
10
  * @param options - Translation options including API settings
11
11
  * @returns Promise that resolves when translation is complete
12
12
  */
13
- export declare function translateFiles(filePaths: ResolvedFiles, placeholderPaths: ResolvedFiles, transformPaths: TransformFiles, format: Format | undefined, options: Settings & TranslateOptions): Promise<void>;
13
+ export declare function translateFiles(filePaths: ResolvedFiles, placeholderPaths: ResolvedFiles, transformPaths: TransformFiles, dataFormat: DataFormat | undefined, options: Settings & TranslateOptions): Promise<void>;
@@ -21,16 +21,16 @@ const SUPPORTED_FORMATS = ['JSX', 'ICU', 'I18NEXT'];
21
21
  * @param filePaths - Resolved file paths for different file types
22
22
  * @param placeholderPaths - Placeholder paths for translated files
23
23
  * @param transformPaths - Transform paths for file naming
24
- * @param format - Format of the data within the files
24
+ * @param dataFormat - Format of the data within the files
25
25
  * @param options - Translation options including API settings
26
26
  * @returns Promise that resolves when translation is complete
27
27
  */
28
- async function translateFiles(filePaths, placeholderPaths, transformPaths, format = 'JSX', options) {
28
+ async function translateFiles(filePaths, placeholderPaths, transformPaths, dataFormat = 'JSX', options) {
29
29
  // Collect all files to translate
30
30
  const allFiles = [];
31
31
  // Process JSON files
32
32
  if (filePaths.json) {
33
- if (!SUPPORTED_FORMATS.includes(format)) {
33
+ if (!SUPPORTED_FORMATS.includes(dataFormat)) {
34
34
  (0, console_1.logErrorAndExit)(console_1.noSupportedFormatError);
35
35
  }
36
36
  const jsonFiles = filePaths.json.map((filePath) => {
@@ -43,7 +43,7 @@ async function translateFiles(filePaths, placeholderPaths, transformPaths, forma
43
43
  content,
44
44
  fileName: relativePath,
45
45
  fileExtension: 'JSON',
46
- format,
46
+ dataFormat,
47
47
  };
48
48
  });
49
49
  allFiles.push(...jsonFiles);
@@ -59,7 +59,7 @@ async function translateFiles(filePaths, placeholderPaths, transformPaths, forma
59
59
  content,
60
60
  fileName: relativePath,
61
61
  fileExtension: fileType.toUpperCase(),
62
- format,
62
+ dataFormat,
63
63
  };
64
64
  });
65
65
  allFiles.push(...files);
@@ -1,10 +1,10 @@
1
1
  import { RetrievedTranslations } from '../../types/api';
2
2
  import { ResolvedFiles } from '../../types';
3
- import { Format } from '../../types/data';
3
+ import { DataFormat } from '../../types/data';
4
4
  /**
5
5
  * Saves translations to a local directory
6
6
  * @param translations - The translations to save
7
7
  * @param translationsDir - The directory to save the translations to
8
8
  * @param fileType - The file type to save the translations as (file extension)
9
9
  */
10
- export declare function saveTranslations(translations: RetrievedTranslations, placeholderPaths: ResolvedFiles, format: Format): Promise<void>;
10
+ export declare function saveTranslations(translations: RetrievedTranslations, placeholderPaths: ResolvedFiles, dataFormat: DataFormat): Promise<void>;
@@ -14,7 +14,7 @@ const parseFilesConfig_1 = require("../../fs/config/parseFilesConfig");
14
14
  * @param translationsDir - The directory to save the translations to
15
15
  * @param fileType - The file type to save the translations as (file extension)
16
16
  */
17
- async function saveTranslations(translations, placeholderPaths, format) {
17
+ async function saveTranslations(translations, placeholderPaths, dataFormat) {
18
18
  for (const translation of translations) {
19
19
  const locale = translation.locale;
20
20
  const translationFiles = (0, parseFilesConfig_1.resolveLocaleFiles)(placeholderPaths, locale);
@@ -27,7 +27,7 @@ async function saveTranslations(translations, placeholderPaths, format) {
27
27
  // Ensure directory exists
28
28
  await node_fs_1.default.promises.mkdir(node_path_1.default.dirname(filepath), { recursive: true });
29
29
  // Handle different file types
30
- if (format === 'JSX') {
30
+ if (dataFormat === 'JSX') {
31
31
  await node_fs_1.default.promises.writeFile(filepath, JSON.stringify(translationData, null, 2));
32
32
  }
33
33
  }
@@ -42,7 +42,7 @@ async function parseNextConfig(filePath) {
42
42
  .filter((locale) => typeof locale === 'string')
43
43
  : undefined;
44
44
  // Ensure approvedLocales is an array of strings
45
- const validLocales = locales && locales.every((locale) => generaltranslation_1.GT.isValidLocale(locale))
45
+ const validLocales = locales && locales.every((locale) => (0, generaltranslation_1.isValidLocale)(locale))
46
46
  ? locales
47
47
  : undefined;
48
48
  // Return the extracted values if they pass type checks or return null
@@ -98,7 +98,7 @@ function parseStrings(importName, path, updates, errors, file) {
98
98
  });
99
99
  }
100
100
  updates.push({
101
- format: 'ICU',
101
+ dataFormat: 'ICU',
102
102
  source,
103
103
  metadata,
104
104
  });
@@ -246,7 +246,7 @@ function parseJSXElement(importAliases, node, updates, errors, file) {
246
246
  return;
247
247
  // <T> is valid here
248
248
  updates.push({
249
- format: 'JSX',
249
+ dataFormat: 'JSX',
250
250
  source: componentObj.tree,
251
251
  metadata: componentObj.props,
252
252
  });
@@ -87,7 +87,7 @@ function processTranslationCall(tPath, updates, errors, file) {
87
87
  });
88
88
  }
89
89
  updates.push({
90
- format: 'ICU',
90
+ dataFormat: 'ICU',
91
91
  source,
92
92
  metadata,
93
93
  });
@@ -63,11 +63,11 @@ async function createDictionaryUpdates(options, dictionaryPath, esbuildConfig) {
63
63
  source: entry,
64
64
  ...(context && { context }),
65
65
  ...(id && { id }),
66
- format: 'ICU',
66
+ dataFormat: 'ICU',
67
67
  }),
68
68
  };
69
69
  updates.push({
70
- format: 'ICU',
70
+ dataFormat: 'ICU',
71
71
  source: entry,
72
72
  metadata,
73
73
  });
@@ -132,7 +132,7 @@ async function createInlineUpdates(options, pkg) {
132
132
  source: update.source,
133
133
  ...(context && { context }),
134
134
  ...(update.metadata.id && { id: update.metadata.id }),
135
- format: update.format,
135
+ dataFormat: update.dataFormat,
136
136
  });
137
137
  update.metadata.hash = hash;
138
138
  }));
@@ -24,7 +24,7 @@ async function getDesiredLocales() {
24
24
  return 'Please enter at least one locale';
25
25
  }
26
26
  for (const locale of localeList) {
27
- if (!generaltranslation_1.GT.isValidLocale(locale)) {
27
+ if (!(0, generaltranslation_1.isValidLocale)(locale)) {
28
28
  return 'Please enter a valid locale (e.g., en, fr, es)';
29
29
  }
30
30
  }
@@ -73,7 +73,7 @@ async function stageProject(settings, pkg) {
73
73
  const updateResponse = await (0, sendUpdates_1.sendUpdates)(updates, {
74
74
  ...settings,
75
75
  timeout: settings.timeout,
76
- format: 'JSX',
76
+ dataFormat: 'JSX',
77
77
  }, pkg);
78
78
  const { versionId, locales } = updateResponse;
79
79
  return { versionId, locales };
@@ -17,7 +17,7 @@ export type JSONDictionary = {
17
17
  export type FlattenedJSONDictionary = {
18
18
  [key: string]: string;
19
19
  };
20
- export type Format = 'JSX' | 'ICU' | 'I18NEXT';
20
+ export type DataFormat = 'JSX' | 'ICU' | 'I18NEXT';
21
21
  export type FileExtension = 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS';
22
22
  export type JsxChildren = string | string[] | any;
23
23
  export type Translations = {
@@ -3,13 +3,13 @@ import { SUPPORTED_FILE_EXTENSIONS } from '../formats/files/supportedFiles';
3
3
  export type Updates = ({
4
4
  metadata: Record<string, any>;
5
5
  } & ({
6
- format: 'JSX';
6
+ dataFormat: 'JSX';
7
7
  source: JsxChildren;
8
8
  } | {
9
- format: 'ICU';
9
+ dataFormat: 'ICU';
10
10
  source: string;
11
11
  } | {
12
- format: 'I18NEXT';
12
+ dataFormat: 'I18NEXT';
13
13
  source: string;
14
14
  }))[];
15
15
  export type Options = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "1.2.25-alpha.10",
3
+ "version": "1.2.25-alpha.12",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [
@@ -79,7 +79,7 @@
79
79
  "esbuild": "^0.25.4",
80
80
  "fast-glob": "^3.3.3",
81
81
  "form-data": "^4.0.2",
82
- "generaltranslation": "^7.0.0-alpha.10",
82
+ "generaltranslation": "^7.0.0-alpha.12",
83
83
  "open": "^10.1.1",
84
84
  "ora": "^8.2.0",
85
85
  "resolve": "^1.22.10",