MCPcopy
hub / github.com/lingodotdev/lingo.dev / frozen

Function frozen

packages/cli/src/cli/cmd/run/frozen.ts:14–182  ·  view source on GitHub ↗
(input: CmdRunContext)

Source from the content-addressed store, hash-verified

12import { resolveOverriddenLocale } from "@lingo.dev/_spec";
13
14export 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);

Callers 1

index.tsFile · 0.85

Calls 9

getBucketsFunction · 0.90
createDeltaProcessorFunction · 0.90
resolveOverriddenLocaleFunction · 0.85
createBucketLoaderFunction · 0.85
logMethod · 0.80
setDefaultLocaleMethod · 0.80
runMethod · 0.65
initMethod · 0.65
pullMethod · 0.65

Tested by

no test coverage detected