gtx-cli 2.0.18 → 2.0.19

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.0.19
4
+
5
+ ### Patch Changes
6
+
7
+ - [#519](https://github.com/generaltranslation/gt/pull/519) [`2ba4848`](https://github.com/generaltranslation/gt/commit/2ba48486603ef5e8e4026d89dc36311ce6505b81) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - feat: exclude files with the [locales] tag
8
+
3
9
  ## 2.0.18
4
10
 
5
11
  ### Patch Changes
@@ -105,7 +105,7 @@ export async function generateSettings(options, cwd = process.cwd()) {
105
105
  mergedOptions.src = mergedOptions.src || DEFAULT_SRC_PATTERNS;
106
106
  // Resolve all glob patterns in the files object
107
107
  mergedOptions.files = mergedOptions.files
108
- ? resolveFiles(mergedOptions.files, mergedOptions.defaultLocale, cwd)
108
+ ? resolveFiles(mergedOptions.files, mergedOptions.defaultLocale, mergedOptions.locales, cwd)
109
109
  : undefined;
110
110
  // Add additional options if provided
111
111
  if (mergedOptions.options) {
@@ -1,4 +1,4 @@
1
- import { FilesOptions, ResolvedFiles, TransformFiles } from '../../types/index.js';
1
+ import { FilesOptions, ResolvedFiles, TransformFiles, TransformOption } from '../../types/index.js';
2
2
  /**
3
3
  * Resolves the files from the files object
4
4
  * Replaces [locale] with the actual locale in the files
@@ -16,8 +16,12 @@ export declare function resolveLocaleFiles(files: ResolvedFiles, locale: string)
16
16
  * @param files - The files object
17
17
  * @returns The resolved files
18
18
  */
19
- export declare function resolveFiles(files: FilesOptions, locale: string, cwd: string): {
19
+ export declare function resolveFiles(files: FilesOptions, locale: string, locales: string[], cwd: string): {
20
20
  resolvedPaths: ResolvedFiles;
21
21
  placeholderPaths: ResolvedFiles;
22
22
  transformPaths: TransformFiles;
23
23
  };
24
+ export declare function expandGlobPatterns(cwd: string, includePatterns: string[], excludePatterns: string[], locale: string, locales: string[], transformPatterns?: TransformOption | string): {
25
+ resolvedPaths: string[];
26
+ placeholderPaths: string[];
27
+ };
@@ -28,7 +28,7 @@ export function resolveLocaleFiles(files, locale) {
28
28
  * @param files - The files object
29
29
  * @returns The resolved files
30
30
  */
31
- export function resolveFiles(files, locale, cwd) {
31
+ export function resolveFiles(files, locale, locales, cwd) {
32
32
  // Initialize result object with empty arrays for each file type
33
33
  const result = {};
34
34
  const placeholderResult = {};
@@ -47,7 +47,7 @@ export function resolveFiles(files, locale, cwd) {
47
47
  }
48
48
  // ==== PLACEHOLDERS ==== //
49
49
  if (files[fileType]?.include) {
50
- const filePaths = expandGlobPatterns(cwd, files[fileType].include, files[fileType]?.exclude || [], locale, transformPaths[fileType] || undefined);
50
+ const filePaths = expandGlobPatterns(cwd, files[fileType].include, files[fileType]?.exclude || [], locale, locales, transformPaths[fileType] || undefined);
51
51
  result[fileType] = filePaths.resolvedPaths;
52
52
  placeholderResult[fileType] = filePaths.placeholderPaths;
53
53
  }
@@ -59,7 +59,7 @@ export function resolveFiles(files, locale, cwd) {
59
59
  };
60
60
  }
61
61
  // Helper function to expand glob patterns
62
- function expandGlobPatterns(cwd, includePatterns, excludePatterns, locale, transformPatterns) {
62
+ export function expandGlobPatterns(cwd, includePatterns, excludePatterns, locale, locales, transformPatterns) {
63
63
  // Expand glob patterns to include all matching files
64
64
  const resolvedPaths = [];
65
65
  const placeholderPaths = [];
@@ -85,7 +85,9 @@ function expandGlobPatterns(cwd, includePatterns, excludePatterns, locale, trans
85
85
  // Resolve the absolute pattern path
86
86
  const absolutePattern = path.resolve(cwd, expandedPattern);
87
87
  // Prepare exclude patterns with locale replaced
88
- const expandedExcludePatterns = excludePatterns.map((p) => path.resolve(cwd, p.replace(/\[locale\]/g, locale)));
88
+ const expandedExcludePatterns = Array.from(new Set(excludePatterns.flatMap((p) => locales.map((targetLocale) => path.resolve(cwd, p
89
+ .replace(/\[locale\]/g, locale)
90
+ .replace(/\[locales\]/g, targetLocale))))));
89
91
  // Use fast-glob to find all matching files, excluding the patterns
90
92
  const matches = fg.sync(absolutePattern, {
91
93
  absolute: true,
@@ -71,7 +71,7 @@ export type FilesOptions = {
71
71
  [K in SupportedFileExtension]?: {
72
72
  include: string[];
73
73
  exclude?: string[];
74
- transform?: string;
74
+ transform?: string | TransformOption;
75
75
  };
76
76
  } & {
77
77
  gt?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.0.18",
3
+ "version": "2.0.19",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [