gtx-cli 1.1.3 → 1.1.5

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.
@@ -72,8 +72,10 @@ function checkFileTranslations(apiKey, baseUrl, data, locales, timeoutDuration,
72
72
  yield (0, downloadFile_1.downloadFile)(baseUrl, apiKey, translationId, outputPath);
73
73
  }
74
74
  }
75
- // Update the spinner text
76
- spinner.suffixText = generateStatusSuffixText(downloadedFiles, fileQueryData);
75
+ // Force a refresh of the spinner display
76
+ const statusText = generateStatusSuffixText(downloadedFiles, fileQueryData);
77
+ // Clear and reapply the suffix to force a refresh
78
+ spinner.suffixText = statusText;
77
79
  }
78
80
  if (downloadedFiles.size === fileQueryData.length) {
79
81
  return true;
@@ -93,44 +95,69 @@ function checkFileTranslations(apiKey, baseUrl, data, locales, timeoutDuration,
93
95
  */
94
96
  function generateStatusSuffixText(downloadedFiles, fileQueryData) {
95
97
  var _a;
96
- const newSuffixText = [
97
- `\n\n` +
98
- chalk_1.default.green(`${downloadedFiles.size}/${fileQueryData.length}`) +
99
- ` translations completed\n`,
100
- ];
101
- // Group by filename for better organization
102
- const fileGroups = new Map();
98
+ // Simple progress indicator
99
+ const progressText = chalk_1.default.green(`[${downloadedFiles.size}/${fileQueryData.length}]`) +
100
+ ` translations completed`;
101
+ // Get terminal height to adapt our output
102
+ const terminalHeight = process.stdout.rows || 24; // Default to 24 if undefined
103
+ // If terminal is very small, just show the basic progress
104
+ if (terminalHeight < 6) {
105
+ return `\n${progressText}`;
106
+ }
107
+ const newSuffixText = [`\n${progressText}`];
108
+ // Organize data by filename
109
+ const fileStatus = new Map();
103
110
  // Initialize with all files and locales from fileQueryData
104
111
  for (const item of fileQueryData) {
105
- if (!fileGroups.has(item.fileName)) {
106
- fileGroups.set(item.fileName, new Set());
112
+ if (!fileStatus.has(item.fileName)) {
113
+ fileStatus.set(item.fileName, {
114
+ completed: new Set(),
115
+ pending: new Set([item.locale]),
116
+ });
117
+ }
118
+ else {
119
+ (_a = fileStatus.get(item.fileName)) === null || _a === void 0 ? void 0 : _a.pending.add(item.locale);
107
120
  }
108
- (_a = fileGroups.get(item.fileName)) === null || _a === void 0 ? void 0 : _a.add(item.locale);
109
121
  }
110
122
  // Mark which ones are completed
111
123
  for (const fileLocale of downloadedFiles) {
112
124
  const [fileName, locale] = fileLocale.split(':');
113
- const completedLocales = fileGroups.get(fileName);
114
- if (completedLocales) {
115
- completedLocales.delete(locale); // Remove from pending
125
+ const status = fileStatus.get(fileName);
126
+ if (status) {
127
+ status.pending.delete(locale);
128
+ status.completed.add(locale);
116
129
  }
117
130
  }
118
- // Display each file with its status
119
- for (const [fileName, pendingLocales] of fileGroups.entries()) {
120
- newSuffixText.push(`\n${chalk_1.default.bold(fileName)}`);
121
- // Show completed locales for this file
122
- for (const fileLocale of downloadedFiles) {
123
- const [currentFileName, locale] = fileLocale.split(':');
124
- if (currentFileName === fileName) {
125
- const localeProperties = (0, generaltranslation_1.getLocaleProperties)(locale);
126
- newSuffixText.push(` ${chalk_1.default.green('✓')} ${chalk_1.default.green(localeProperties.code)}`);
127
- }
131
+ // Calculate how many files we can show based on terminal height
132
+ // Each file takes 1 line now
133
+ const filesArray = Array.from(fileStatus.entries());
134
+ const maxFilesToShow = Math.min(filesArray.length, terminalHeight - 3 // Header + progress + buffer
135
+ );
136
+ // Display each file with its status on a single line
137
+ for (let i = 0; i < maxFilesToShow; i++) {
138
+ const [fileName, status] = filesArray[i];
139
+ // Create condensed locale status
140
+ const localeStatuses = [];
141
+ // Add completed locales
142
+ if (status.completed.size > 0) {
143
+ const completedCodes = Array.from(status.completed)
144
+ .map((locale) => (0, generaltranslation_1.getLocaleProperties)(locale).code)
145
+ .join(', ');
146
+ localeStatuses.push(chalk_1.default.green(`${completedCodes}`));
128
147
  }
129
- // Show pending locales for this file
130
- for (const locale of pendingLocales) {
131
- const localeProperties = (0, generaltranslation_1.getLocaleProperties)(locale);
132
- newSuffixText.push(` ${chalk_1.default.yellow('[==>')} ${chalk_1.default.yellow(localeProperties.code)}`);
148
+ // Add pending locales
149
+ if (status.pending.size > 0) {
150
+ const pendingCodes = Array.from(status.pending)
151
+ .map((locale) => (0, generaltranslation_1.getLocaleProperties)(locale).code)
152
+ .join(', ');
153
+ localeStatuses.push(chalk_1.default.yellow(`${pendingCodes}`));
133
154
  }
155
+ // Format the line
156
+ newSuffixText.push(`${chalk_1.default.bold(fileName)} [${localeStatuses.join(', ')}]`);
157
+ }
158
+ // If we couldn't show all files, add an indicator
159
+ if (filesArray.length > maxFilesToShow) {
160
+ newSuffixText.push(`... and ${filesArray.length - maxFilesToShow} more files`);
134
161
  }
135
162
  return newSuffixText.join('\n');
136
163
  }
package/dist/cli/react.js CHANGED
@@ -456,7 +456,8 @@ class ReactCLI extends base_1.BaseCLI {
456
456
  }
457
457
  }
458
458
  else {
459
- throw new Error(errors_1.noTranslationsError);
459
+ console.log(chalk_1.default.red(errors_1.noTranslationsError));
460
+ process.exit(0);
460
461
  }
461
462
  });
462
463
  }
@@ -1,4 +1,4 @@
1
- export declare const noTranslationsError = "No updates found! Are you sure you're running this command in the right directory?";
1
+ export declare const noTranslationsError = "No in-line content or dictionaries were found. Are you sure you're running this command in the right directory?";
2
2
  export declare const noLocalesError = "No locales found! Please provide a list of locales to translate to, or specify them in your gt.config.json file.";
3
3
  export declare const noDefaultLocaleError = "No default locale found! Please provide a default locale, or specify it in your gt.config.json file.";
4
4
  export declare const noFilesError = "No files configuration found! Please make sure your files are configured correctly in your gt.config.json file.";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noProjectIdError = exports.noApiKeyError = exports.noSupportedDataFormatError = exports.noDataFormatError = exports.noSourceFileError = exports.noFilesError = exports.noDefaultLocaleError = exports.noLocalesError = exports.noTranslationsError = void 0;
4
- exports.noTranslationsError = `No updates found! Are you sure you're running this command in the right directory?`;
4
+ exports.noTranslationsError = `No in-line content or dictionaries were found. Are you sure you're running this command in the right directory?`;
5
5
  exports.noLocalesError = `No locales found! Please provide a list of locales to translate to, or specify them in your gt.config.json file.`;
6
6
  exports.noDefaultLocaleError = `No default locale found! Please provide a default locale, or specify it in your gt.config.json file.`;
7
7
  exports.noFilesError = `No files configuration found! Please make sure your files are configured correctly in your gt.config.json file.`;
@@ -35,7 +35,7 @@ function resolveLocaleFiles(files, locale) {
35
35
  * @returns The resolved files
36
36
  */
37
37
  function resolveFiles(files, locale) {
38
- var _a, _b, _c, _d, _e;
38
+ var _a, _b, _c, _d, _e, _f, _g, _h;
39
39
  // Initialize result object with empty arrays for each file type
40
40
  const result = {};
41
41
  const placeholderResult = {};
@@ -47,7 +47,7 @@ function resolveFiles(files, locale) {
47
47
  process.exit(1);
48
48
  }
49
49
  if (files.json.include.length === 1) {
50
- const jsonPaths = expandGlobPatterns([files.json.include[0]], locale);
50
+ const jsonPaths = expandGlobPatterns([files.json.include[0]], ((_b = files.json) === null || _b === void 0 ? void 0 : _b.exclude) || [], locale);
51
51
  if (jsonPaths.resolvedPaths.length > 1) {
52
52
  console.error('JSON glob pattern matched multiple files. Only one JSON file is supported.');
53
53
  process.exit(1);
@@ -57,22 +57,22 @@ function resolveFiles(files, locale) {
57
57
  }
58
58
  }
59
59
  // Process MD files
60
- if ((_b = files.md) === null || _b === void 0 ? void 0 : _b.include) {
61
- const mdPaths = expandGlobPatterns(files.md.include, locale);
60
+ if ((_c = files.md) === null || _c === void 0 ? void 0 : _c.include) {
61
+ const mdPaths = expandGlobPatterns(files.md.include, ((_d = files.md) === null || _d === void 0 ? void 0 : _d.exclude) || [], locale);
62
62
  result.md = mdPaths.resolvedPaths;
63
63
  placeholderResult.md = mdPaths.placeholderPaths;
64
64
  }
65
65
  // Process MDX files
66
- if ((_c = files.mdx) === null || _c === void 0 ? void 0 : _c.include) {
67
- const mdxPaths = expandGlobPatterns(files.mdx.include, locale);
66
+ if ((_e = files.mdx) === null || _e === void 0 ? void 0 : _e.include) {
67
+ const mdxPaths = expandGlobPatterns(files.mdx.include, ((_f = files.mdx) === null || _f === void 0 ? void 0 : _f.exclude) || [], locale);
68
68
  result.mdx = mdxPaths.resolvedPaths;
69
69
  placeholderResult.mdx = mdxPaths.placeholderPaths;
70
70
  }
71
71
  // ==== TRANSFORMS ==== //
72
- if (((_d = files.mdx) === null || _d === void 0 ? void 0 : _d.transform) && !Array.isArray(files.mdx.transform)) {
72
+ if (((_g = files.mdx) === null || _g === void 0 ? void 0 : _g.transform) && !Array.isArray(files.mdx.transform)) {
73
73
  transformPaths.mdx = files.mdx.transform;
74
74
  }
75
- if (((_e = files.md) === null || _e === void 0 ? void 0 : _e.transform) && !Array.isArray(files.md.transform)) {
75
+ if (((_h = files.md) === null || _h === void 0 ? void 0 : _h.transform) && !Array.isArray(files.md.transform)) {
76
76
  transformPaths.md = files.md.transform;
77
77
  }
78
78
  return {
@@ -82,11 +82,12 @@ function resolveFiles(files, locale) {
82
82
  };
83
83
  }
84
84
  // Helper function to expand glob patterns
85
- function expandGlobPatterns(patterns, locale) {
85
+ function expandGlobPatterns(includePatterns, excludePatterns, locale) {
86
86
  // Expand glob patterns to include all matching files
87
87
  const resolvedPaths = [];
88
88
  const placeholderPaths = [];
89
- for (const pattern of patterns) {
89
+ // Process include patterns
90
+ for (const pattern of includePatterns) {
90
91
  // Track positions where [locale] appears in the original pattern
91
92
  const localePositions = [];
92
93
  let searchIndex = 0;
@@ -105,8 +106,13 @@ function expandGlobPatterns(patterns, locale) {
105
106
  expandedPattern.includes('{')) {
106
107
  // Resolve the absolute pattern path
107
108
  const absolutePattern = path_1.default.resolve(process.cwd(), expandedPattern);
108
- // Use fast-glob to find all matching files
109
- const matches = fast_glob_1.default.sync(absolutePattern, { absolute: true });
109
+ // Prepare exclude patterns with locale replaced
110
+ const expandedExcludePatterns = excludePatterns.map((p) => path_1.default.resolve(process.cwd(), p.replace(/\[locale\]/g, locale)));
111
+ // Use fast-glob to find all matching files, excluding the patterns
112
+ const matches = fast_glob_1.default.sync(absolutePattern, {
113
+ absolute: true,
114
+ ignore: expandedExcludePatterns,
115
+ });
110
116
  resolvedPaths.push(...matches);
111
117
  // For each match, create a version with [locale] in the correct positions
112
118
  matches.forEach((match) => {
@@ -136,13 +142,28 @@ function expandGlobPatterns(patterns, locale) {
136
142
  });
137
143
  }
138
144
  else {
139
- // If it's not a glob pattern, just add the resolved path
145
+ // If it's not a glob pattern, just add the resolved path if it's not excluded
140
146
  const absolutePath = path_1.default.resolve(process.cwd(), expandedPattern);
141
- resolvedPaths.push(absolutePath);
142
- // For non-glob patterns, we can directly replace locale with [locale]
143
- // at the tracked positions in the resolved path
144
- let originalPath = path_1.default.resolve(process.cwd(), pattern);
145
- placeholderPaths.push(originalPath);
147
+ // Check if this path should be excluded
148
+ const expandedExcludePatterns = excludePatterns.map((p) => path_1.default.resolve(process.cwd(), p.replace(/\[locale\]/g, locale)));
149
+ // Only include if not matched by any exclude pattern
150
+ const shouldExclude = expandedExcludePatterns.some((excludePattern) => {
151
+ if (excludePattern.includes('*') ||
152
+ excludePattern.includes('?') ||
153
+ excludePattern.includes('{')) {
154
+ return fast_glob_1.default
155
+ .sync(excludePattern, { absolute: true })
156
+ .includes(absolutePath);
157
+ }
158
+ return absolutePath === excludePattern;
159
+ });
160
+ if (!shouldExclude) {
161
+ resolvedPaths.push(absolutePath);
162
+ // For non-glob patterns, we can directly replace locale with [locale]
163
+ // at the tracked positions in the resolved path
164
+ let originalPath = path_1.default.resolve(process.cwd(), pattern);
165
+ placeholderPaths.push(originalPath);
166
+ }
146
167
  }
147
168
  }
148
169
  return { resolvedPaths, placeholderPaths };
@@ -11,10 +11,6 @@ const defaultVariableNames = {
11
11
  exports.baseVariablePrefix = '_gt_';
12
12
  function getVariableName(props = {}, variableType) {
13
13
  var _a;
14
- if (props.name)
15
- return props.name;
16
- if (props['data-_gt-variable-name'])
17
- return props['data-_gt-variable-name'];
18
14
  const baseVariableName = defaultVariableNames[variableType] || 'value';
19
15
  return `${exports.baseVariablePrefix}${baseVariableName}_${(_a = props['data-_gt']) === null || _a === void 0 ? void 0 : _a.id}`;
20
16
  }
@@ -62,16 +62,20 @@ export interface ContentScanner {
62
62
  export type FilesOptions = {
63
63
  json?: {
64
64
  include: string[];
65
+ exclude?: string[];
65
66
  };
66
67
  yaml?: {
67
68
  include: string[];
69
+ exclude?: string[];
68
70
  };
69
71
  md?: {
70
72
  include: string[];
73
+ exclude?: string[];
71
74
  transform?: string;
72
75
  };
73
76
  mdx?: {
74
77
  include: string[];
78
+ exclude?: string[];
75
79
  transform?: string;
76
80
  };
77
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "scripts": {