gtx-cli 1.2.9 → 1.2.10-alpha.2
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/.env +2 -0
- package/dist/config/validateSettings.js +2 -1
- package/dist/fs/config/parseFilesConfig.js +32 -61
- package/package.json +1 -1
package/.env
ADDED
|
@@ -15,7 +15,8 @@ function validateSettings(settings) {
|
|
|
15
15
|
}
|
|
16
16
|
// defaultLocale cannot be a superset of any other locale
|
|
17
17
|
if (settings.defaultLocale &&
|
|
18
|
-
settings.locales.some((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale)
|
|
18
|
+
settings.locales.some((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale) &&
|
|
19
|
+
!(0, generaltranslation_1.isSupersetLocale)(locale, settings.defaultLocale))) {
|
|
19
20
|
const locale = settings.locales.find((locale) => (0, generaltranslation_1.isSupersetLocale)(settings.defaultLocale, locale));
|
|
20
21
|
(0, console_1.logErrorAndExit)(`defaultLocale: ${settings.defaultLocale} is a superset of another locale (${locale})! Please change the defaultLocale to a more specific locale.`);
|
|
21
22
|
}
|
|
@@ -87,71 +87,42 @@ function expandGlobPatterns(includePatterns, excludePatterns, locale, transformP
|
|
|
87
87
|
searchIndex = foundIndex + localeTag.length;
|
|
88
88
|
}
|
|
89
89
|
const expandedPattern = pattern.replace(/\[locale\]/g, locale);
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (i < patternParts.length) {
|
|
118
|
-
if (patternParts[i].includes(localeTag)) {
|
|
119
|
-
// This segment should have the locale replaced
|
|
120
|
-
pathParts[i] = pathParts[i].replace(locale, localeTag);
|
|
121
|
-
}
|
|
90
|
+
// Resolve the absolute pattern path
|
|
91
|
+
const absolutePattern = node_path_1.default.resolve(process.cwd(), expandedPattern);
|
|
92
|
+
// Prepare exclude patterns with locale replaced
|
|
93
|
+
const expandedExcludePatterns = excludePatterns.map((p) => node_path_1.default.resolve(process.cwd(), p.replace(/\[locale\]/g, locale)));
|
|
94
|
+
// Use fast-glob to find all matching files, excluding the patterns
|
|
95
|
+
const matches = fast_glob_1.default.sync(absolutePattern, {
|
|
96
|
+
absolute: true,
|
|
97
|
+
ignore: expandedExcludePatterns,
|
|
98
|
+
});
|
|
99
|
+
resolvedPaths.push(...matches);
|
|
100
|
+
// For each match, create a version with [locale] in the correct positions
|
|
101
|
+
matches.forEach((match) => {
|
|
102
|
+
// Convert to relative path to make replacement easier
|
|
103
|
+
const relativePath = node_path_1.default.relative(process.cwd(), match);
|
|
104
|
+
let originalRelativePath = relativePath;
|
|
105
|
+
// Replace locale with [locale] at each tracked position
|
|
106
|
+
if (localePositions.length > 0) {
|
|
107
|
+
// We need to account for path resolution differences
|
|
108
|
+
// This is a simplified approach - we'll replace all instances of the locale
|
|
109
|
+
// but only in path segments where we expect it based on the original pattern
|
|
110
|
+
const pathParts = relativePath.split(node_path_1.default.sep);
|
|
111
|
+
const patternParts = pattern.split(/[\/\\]/); // Handle both slash types
|
|
112
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
113
|
+
if (i < patternParts.length) {
|
|
114
|
+
if (patternParts[i].includes(localeTag)) {
|
|
115
|
+
// This segment should have the locale replaced
|
|
116
|
+
pathParts[i] = pathParts[i].replace(locale, localeTag);
|
|
122
117
|
}
|
|
123
118
|
}
|
|
124
|
-
originalRelativePath = pathParts.join(node_path_1.default.sep);
|
|
125
119
|
}
|
|
126
|
-
|
|
127
|
-
const originalPath = node_path_1.default.resolve(process.cwd(), originalRelativePath);
|
|
128
|
-
placeholderPaths.push(originalPath);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
// If it's not a glob pattern, just add the resolved path if it's not excluded
|
|
133
|
-
const absolutePath = node_path_1.default.resolve(process.cwd(), expandedPattern);
|
|
134
|
-
// Check if this path should be excluded
|
|
135
|
-
const expandedExcludePatterns = excludePatterns.map((p) => node_path_1.default.resolve(process.cwd(), p.replace(/\[locale\]/g, locale)));
|
|
136
|
-
// Only include if not matched by any exclude pattern
|
|
137
|
-
const shouldExclude = expandedExcludePatterns.some((excludePattern) => {
|
|
138
|
-
if (excludePattern.includes('*') ||
|
|
139
|
-
excludePattern.includes('?') ||
|
|
140
|
-
excludePattern.includes('{')) {
|
|
141
|
-
return fast_glob_1.default
|
|
142
|
-
.sync(excludePattern, { absolute: true })
|
|
143
|
-
.includes(absolutePath);
|
|
144
|
-
}
|
|
145
|
-
return absolutePath === excludePattern;
|
|
146
|
-
});
|
|
147
|
-
if (!shouldExclude) {
|
|
148
|
-
resolvedPaths.push(absolutePath);
|
|
149
|
-
// For non-glob patterns, we can directly replace locale with [locale]
|
|
150
|
-
// at the tracked positions in the resolved path
|
|
151
|
-
let originalPath = node_path_1.default.resolve(process.cwd(), pattern);
|
|
152
|
-
placeholderPaths.push(originalPath);
|
|
120
|
+
originalRelativePath = pathParts.join(node_path_1.default.sep);
|
|
153
121
|
}
|
|
154
|
-
|
|
122
|
+
// Convert back to absolute path
|
|
123
|
+
const originalPath = node_path_1.default.resolve(process.cwd(), originalRelativePath);
|
|
124
|
+
placeholderPaths.push(originalPath);
|
|
125
|
+
});
|
|
155
126
|
}
|
|
156
127
|
return { resolvedPaths, placeholderPaths };
|
|
157
128
|
}
|