gtx-cli 2.0.18 → 2.0.20
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,17 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.0.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#521](https://github.com/generaltranslation/gt/pull/521) [`6b137bc`](https://github.com/generaltranslation/gt/commit/6b137bcf0b2aaf50adacd5fb03ed64525fb12473) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - refactor: add support for experimental flags in config file
|
|
8
|
+
|
|
9
|
+
## 2.0.19
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
3
15
|
## 2.0.18
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -76,7 +76,7 @@ export async function generateSettings(options, cwd = process.cwd()) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
// merge options
|
|
79
|
-
|
|
79
|
+
let mergedOptions = { ...gtConfig, ...options };
|
|
80
80
|
// merge locales
|
|
81
81
|
mergedOptions.locales = Array.from(new Set([...(gtConfig.locales || []), ...(options.locales || [])]));
|
|
82
82
|
// Add apiKey if not provided
|
|
@@ -105,8 +105,15 @@ 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
|
+
mergedOptions = {
|
|
111
|
+
...mergedOptions,
|
|
112
|
+
experimentalLocalizeStaticImports: gtConfig.options?.experimentalLocalizeStaticImports,
|
|
113
|
+
experimentalLocalizeStaticUrls: gtConfig.options?.experimentalLocalizeStaticUrls,
|
|
114
|
+
experimentalHideDefaultLocale: gtConfig.options?.experimentalHideDefaultLocale,
|
|
115
|
+
experimentalFlattenJsonFiles: gtConfig.options?.experimentalFlattenJsonFiles,
|
|
116
|
+
};
|
|
110
117
|
// Add additional options if provided
|
|
111
118
|
if (mergedOptions.options) {
|
|
112
119
|
if (mergedOptions.options.jsonSchema) {
|
|
@@ -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.
|
|
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,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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?: {
|
|
@@ -110,6 +110,10 @@ export type AdditionalOptions = {
|
|
|
110
110
|
docsImportPattern?: string;
|
|
111
111
|
docsHideDefaultLocaleImport?: boolean;
|
|
112
112
|
copyFiles?: string[];
|
|
113
|
+
experimentalLocalizeStaticImports?: boolean;
|
|
114
|
+
experimentalLocalizeStaticUrls?: boolean;
|
|
115
|
+
experimentalHideDefaultLocale?: boolean;
|
|
116
|
+
experimentalFlattenJsonFiles?: boolean;
|
|
113
117
|
};
|
|
114
118
|
export type JsonSchema = {
|
|
115
119
|
preset?: 'mintlify';
|