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

Function execute

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

Source from the content-addressed store, hash-verified

12const WARN_CONCURRENCY_COUNT = 30;
13
14export default async function execute(input: CmdRunContext) {
15 const effectiveConcurrency = Math.min(
16 input.flags.concurrency,
17 input.tasks.length,
18 );
19
20 if (effectiveConcurrency >= WARN_CONCURRENCY_COUNT) {
21 console.warn(
22 chalk.yellow(
23 `⚠️ High concurrency (${effectiveConcurrency}) may cause failures in some environments.`,
24 ),
25 );
26 }
27
28 console.log(chalk.hex(colors.orange)(`[Localization]`));
29
30 return new Listr<CmdRunContext>(
31 [
32 {
33 title: "Initializing localization engine",
34 task: async (ctx, task) => {
35 task.title = `Localization engine ${chalk.hex(colors.green)("ready")} (${ctx.localizer!.id})`;
36 },
37 },
38 {
39 title: `Processing localization tasks ${chalk.dim(
40 `(tasks: ${input.tasks.length}, concurrency: ${effectiveConcurrency})`,
41 )}`,
42 task: async (ctx, task) => {
43 if (input.tasks.length < 1) {
44 task.title = `Skipping, nothing to localize.`;
45 task.skip();
46 return;
47 }
48
49 // Preload checksums for all unique bucket path patterns before starting any workers
50 const initialChecksumsMap = new Map<string, Record<string, string>>();
51 const uniqueBucketPatterns = _.uniq(
52 ctx.tasks.map((t) => t.bucketPathPattern),
53 );
54 for (const bucketPathPattern of uniqueBucketPatterns) {
55 const deltaProcessor = createDeltaProcessor(bucketPathPattern);
56 const checksums = await deltaProcessor.loadChecksums();
57 initialChecksumsMap.set(bucketPathPattern, checksums);
58 }
59
60 const i18nLimiter = pLimit(effectiveConcurrency);
61 const ioLimiter = pLimit(1);
62
63 const perFileIoLimiters = new Map<string, LimitFunction>();
64 const getFileIoLimiter = (
65 bucketPathPattern: string,
66 ): LimitFunction => {
67 const lockKey = bucketPathPattern;
68
69 if (!perFileIoLimiters.has(lockKey)) {
70 perFileIoLimiters.set(lockKey, pLimit(1));
71 }

Callers 2

triggerRetranslationFunction · 0.85
index.tsFile · 0.85

Calls 7

createDeltaProcessorFunction · 0.90
createWorkerTaskFunction · 0.85
warnMethod · 0.80
logMethod · 0.80
runMethod · 0.65
setMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected