gtx-cli 2.3.4 → 2.3.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#687](https://github.com/generaltranslation/gt/pull/687) [`99a1958`](https://github.com/generaltranslation/gt/commit/99a1958124d532bb3817f76a69d5232d9eb26f76) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: showing superfluous warning for composite json paths
|
|
8
|
+
|
|
3
9
|
## 2.3.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -108,8 +108,13 @@ export async function generateSettings(options, cwd = process.cwd()) {
|
|
|
108
108
|
// Populate src if not provided
|
|
109
109
|
mergedOptions.src = mergedOptions.src || DEFAULT_SRC_PATTERNS;
|
|
110
110
|
// Resolve all glob patterns in the files object
|
|
111
|
+
const compositePatterns = [
|
|
112
|
+
...Object.entries(mergedOptions.options?.jsonSchema || {}),
|
|
113
|
+
]
|
|
114
|
+
.filter(([, schema]) => schema.composite)
|
|
115
|
+
.map(([key]) => key);
|
|
111
116
|
mergedOptions.files = mergedOptions.files
|
|
112
|
-
? resolveFiles(mergedOptions.files, mergedOptions.defaultLocale, mergedOptions.locales, cwd)
|
|
117
|
+
? resolveFiles(mergedOptions.files, mergedOptions.defaultLocale, mergedOptions.locales, cwd, compositePatterns)
|
|
113
118
|
: undefined;
|
|
114
119
|
mergedOptions.options = {
|
|
115
120
|
...(mergedOptions.options || {}),
|
|
@@ -16,12 +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, locales: string[], cwd: string): {
|
|
19
|
+
export declare function resolveFiles(files: FilesOptions, locale: string, locales: string[], cwd: string, compositePatterns?: 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): {
|
|
24
|
+
export declare function expandGlobPatterns(cwd: string, includePatterns: string[], excludePatterns: string[], locale: string, locales: string[], transformPatterns?: TransformOption | string, compositePatterns?: string[]): {
|
|
25
25
|
resolvedPaths: string[];
|
|
26
26
|
placeholderPaths: string[];
|
|
27
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, locales, cwd) {
|
|
31
|
+
export function resolveFiles(files, locale, locales, cwd, compositePatterns) {
|
|
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, locales, cwd) {
|
|
|
47
47
|
}
|
|
48
48
|
// ==== PLACEHOLDERS ==== //
|
|
49
49
|
if (files[fileType]?.include) {
|
|
50
|
-
const filePaths = expandGlobPatterns(cwd, files[fileType].include, files[fileType]?.exclude || [], locale, locales, transformPaths[fileType] || undefined);
|
|
50
|
+
const filePaths = expandGlobPatterns(cwd, files[fileType].include, files[fileType]?.exclude || [], locale, locales, transformPaths[fileType] || undefined, compositePatterns);
|
|
51
51
|
result[fileType] = filePaths.resolvedPaths;
|
|
52
52
|
placeholderResult[fileType] = filePaths.placeholderPaths;
|
|
53
53
|
}
|
|
@@ -59,7 +59,7 @@ export function resolveFiles(files, locale, locales, cwd) {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
// Helper function to expand glob patterns
|
|
62
|
-
export function expandGlobPatterns(cwd, includePatterns, excludePatterns, locale, locales, transformPatterns) {
|
|
62
|
+
export function expandGlobPatterns(cwd, includePatterns, excludePatterns, locale, locales, transformPatterns, compositePatterns) {
|
|
63
63
|
// Expand glob patterns to include all matching files
|
|
64
64
|
const resolvedPaths = [];
|
|
65
65
|
const placeholderPaths = [];
|
|
@@ -68,7 +68,10 @@ export function expandGlobPatterns(cwd, includePatterns, excludePatterns, locale
|
|
|
68
68
|
// Track positions where [locale] appears in the original pattern
|
|
69
69
|
// It must be included in the pattern, otherwise the CLI tool will not be able to find the correct output path
|
|
70
70
|
// Warn if it's not included
|
|
71
|
-
if
|
|
71
|
+
// Ignore if is composite pattern
|
|
72
|
+
if (!pattern.includes('[locale]') &&
|
|
73
|
+
!transformPatterns &&
|
|
74
|
+
!compositePatterns?.includes(pattern)) {
|
|
72
75
|
logWarning(chalk.yellow(`Pattern "${pattern}" does not include [locale], so the CLI tool may incorrectly save translated files.`));
|
|
73
76
|
}
|
|
74
77
|
const localePositions = [];
|