(input: CmdRunContext)
| 12 | import { resolveOverriddenLocale } from "@lingo.dev/_spec"; |
| 13 | |
| 14 | export default async function frozen(input: CmdRunContext) { |
| 15 | console.log(chalk.hex(colors.orange)("[Frozen]")); |
| 16 | |
| 17 | // Prepare filtered buckets consistently with the planning step |
| 18 | let buckets = getBuckets(input.config!); |
| 19 | if (input.flags.bucket?.length) { |
| 20 | buckets = buckets.filter((b) => input.flags.bucket!.includes(b.type)); |
| 21 | } |
| 22 | |
| 23 | if (input.flags.file?.length) { |
| 24 | buckets = buckets |
| 25 | .map((bucket: any) => { |
| 26 | const paths = bucket.paths.filter((p: any) => |
| 27 | input.flags.file!.some( |
| 28 | (f) => p.pathPattern.includes(f) || minimatch(p.pathPattern, f), |
| 29 | ), |
| 30 | ); |
| 31 | return { ...bucket, paths }; |
| 32 | }) |
| 33 | .filter((bucket: any) => bucket.paths.length > 0); |
| 34 | } |
| 35 | |
| 36 | const _sourceLocale = input.flags.sourceLocale || input.config!.locale.source; |
| 37 | const _targetLocales = |
| 38 | input.flags.targetLocale || input.config!.locale.targets; |
| 39 | |
| 40 | return new Listr<CmdRunContext>( |
| 41 | [ |
| 42 | { |
| 43 | title: "Setting up localization cache", |
| 44 | task: async (_ctx, task) => { |
| 45 | const checkLockfileProcessor = createDeltaProcessor(""); |
| 46 | const lockfileExists = |
| 47 | await checkLockfileProcessor.checkIfLockExists(); |
| 48 | if (!lockfileExists) { |
| 49 | for (const bucket of buckets) { |
| 50 | for (const bucketPath of bucket.paths) { |
| 51 | const resolvedSourceLocale = resolveOverriddenLocale( |
| 52 | _sourceLocale, |
| 53 | bucketPath.delimiter, |
| 54 | ); |
| 55 | |
| 56 | const loader = createBucketLoader( |
| 57 | bucket.type, |
| 58 | bucketPath.pathPattern, |
| 59 | { |
| 60 | defaultLocale: resolvedSourceLocale, |
| 61 | injectLocale: bucket.injectLocale, |
| 62 | formatter: input.config!.formatter, |
| 63 | keyColumn: bucket.keyColumn, |
| 64 | }, |
| 65 | bucket.lockedKeys, |
| 66 | bucket.lockedPatterns, |
| 67 | bucket.ignoredKeys, |
| 68 | bucket.preservedKeys, |
| 69 | bucket.localizableKeys, |
| 70 | ); |
| 71 | loader.setDefaultLocale(resolvedSourceLocale); |
no test coverage detected