From e63dd2ef17ccc5795407e4d43c4adef5810e4cd9 Mon Sep 17 00:00:00 2001 From: Pruthvi Parmar Date: Thu, 30 Oct 2025 01:13:53 +0530 Subject: [PATCH 1/2] feat(cli): add filters to show files command(#1312) Add --bucket, --target-locale, and --file filter options to the show files command, mirroring the filtering capabilities available in the run command. Fixes #1312 --- packages/cli/src/cli/cmd/show/files.ts | 42 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/cli/cmd/show/files.ts b/packages/cli/src/cli/cmd/show/files.ts index 6cd4ab598..a4d29a2d6 100644 --- a/packages/cli/src/cli/cmd/show/files.ts +++ b/packages/cli/src/cli/cmd/show/files.ts @@ -1,6 +1,7 @@ import { Command } from "interactive-commander"; import _ from "lodash"; import Ora from "ora"; +import { minimatch } from "minimatch"; import { getConfig } from "../../utils/config"; import { CLIError } from "../../utils/errors"; import { getBuckets } from "../../utils/buckets"; @@ -19,6 +20,21 @@ export default new Command() "--target", "Only list the target locale variants for each configured locale", ) + .option( + "--bucket ", + "Limit processing to specific bucket types defined in i18n.json (e.g., json, yaml, android). Repeat the flag to include multiple bucket types. Defaults to all configured buckets", + (val: string, prev: string[]) => (prev ? [...prev, val] : [val]), + ) + .option( + "--target-locale ", + "Limit processing to the listed target locale codes from i18n.json. Repeat the flag to include multiple locales. Defaults to all configured target locales", + (val: string, prev: string[]) => (prev ? [...prev, val] : [val]), + ) + .option( + "--file ", + "Filter bucket path pattern values by substring match. Examples: messages.json or locale/. Repeat to add multiple filters", + (val: string, prev: string[]) => (prev ? [...prev, val] : [val]), + ) .helpOption("-h, --help", "Show help") .action(async (type) => { const ora = Ora(); @@ -34,9 +50,29 @@ export default new Command() }); } - const buckets = getBuckets(i18nConfig); + // Get all buckets and apply bucket filter if specified + let buckets = getBuckets(i18nConfig); + if (type.bucket) { + buckets = buckets.filter((b) => type.bucket.includes(b.type)); + } + + // Apply target-locale filter if specified + const targetLocales = type.targetLocale || i18nConfig.locale.targets; + for (const bucket of buckets) { for (const bucketConfig of bucket.paths) { + // Apply file filter if specified + if (type.file) { + const matchesFilter = type.file.some( + (f: string) => + bucketConfig.pathPattern.includes(f) || + minimatch(bucketConfig.pathPattern, f), + ); + if (!matchesFilter) { + continue; + } + } + const sourceLocale = resolveOverriddenLocale( i18nConfig.locale.source, bucketConfig.delimiter, @@ -45,8 +81,8 @@ export default new Command() /\[locale\]/g, sourceLocale, ); - const targetPaths = i18nConfig.locale.targets.map( - (_targetLocale) => { + const targetPaths = targetLocales.map( + (_targetLocale: string) => { const targetLocale = resolveOverriddenLocale( _targetLocale, bucketConfig.delimiter, From 0b7e58ccba1176209a477569e7fa78eed0ed5555 Mon Sep 17 00:00:00 2001 From: Pruthviraj Parmar <145219675+Pruthvi-Parmar@users.noreply.github.com> Date: Fri, 14 Nov 2025 11:58:02 +0530 Subject: [PATCH 2/2] Update packages/cli/src/cli/cmd/show/files.ts fix: correct file filter matching logic Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/cli/src/cli/cmd/show/files.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli/src/cli/cmd/show/files.ts b/packages/cli/src/cli/cmd/show/files.ts index a4d29a2d6..bdfe97c21 100644 --- a/packages/cli/src/cli/cmd/show/files.ts +++ b/packages/cli/src/cli/cmd/show/files.ts @@ -66,6 +66,7 @@ export default new Command() const matchesFilter = type.file.some( (f: string) => bucketConfig.pathPattern.includes(f) || + minimatch(bucketConfig.pathPattern, `*${f}*`) || minimatch(bucketConfig.pathPattern, f), ); if (!matchesFilter) {