gtx-cli 1.1.3 → 1.1.4

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/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 };
@@ -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.4",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "scripts": {