MCPcopy Index your code
hub / github.com/lingodotdev/lingo.dev / createWorkerTask

Function createWorkerTask

packages/cli/src/cli/cmd/run/execute.ts:149–325  ·  view source on GitHub ↗
(args: {
  ctx: CmdRunContext;
  assignedTasks: CmdRunTask[];
  ioLimiter: LimitFunction;
  i18nLimiter: LimitFunction;
  onDone: () => void;
  initialChecksumsMap: Map<string, Record<string, string>>;
  getFileIoLimiter: (bucketPathPattern: string) => LimitFunction;
})

Source from the content-addressed store, hash-verified

147}
148
149function createWorkerTask(args: {
150 ctx: CmdRunContext;
151 assignedTasks: CmdRunTask[];
152 ioLimiter: LimitFunction;
153 i18nLimiter: LimitFunction;
154 onDone: () => void;
155 initialChecksumsMap: Map<string, Record<string, string>>;
156 getFileIoLimiter: (bucketPathPattern: string) => LimitFunction;
157}): ListrTask {
158 return {
159 title: "Initializing...",
160 task: async (_subCtx: any, subTask: any) => {
161 for (const assignedTask of args.assignedTasks) {
162 subTask.title = createWorkerStatusMessage({
163 assignedTask,
164 percentage: 0,
165 });
166 const bucketLoader = createLoaderForTask(assignedTask);
167 const deltaProcessor = createDeltaProcessor(
168 assignedTask.bucketPathPattern,
169 );
170
171 // Get initial checksums from the preloaded map
172 const initialChecksums =
173 args.initialChecksumsMap.get(assignedTask.bucketPathPattern) || {};
174
175 const taskResult = await args.i18nLimiter(async () => {
176 try {
177 // Pull operations must be serialized per-file for single-file formats
178 // where multiple locales share the same file (e.g., xcode-xcstrings)
179 const fileIoLimiter = args.getFileIoLimiter(
180 assignedTask.bucketPathPattern,
181 );
182 const sourceData = await fileIoLimiter(async () =>
183 bucketLoader.pull(assignedTask.sourceLocale),
184 );
185 const hints = await fileIoLimiter(async () =>
186 bucketLoader.pullHints(),
187 );
188 const targetData = await fileIoLimiter(async () =>
189 bucketLoader.pull(assignedTask.targetLocale),
190 );
191 const delta = await deltaProcessor.calculateDelta({
192 sourceData,
193 targetData,
194 checksums: initialChecksums,
195 });
196
197 const processableData = computeProcessableData(
198 sourceData,
199 delta,
200 args.ctx.flags.force,
201 assignedTask.onlyKeys,
202 );
203
204 if (!Object.keys(processableData).length) {
205 await fileIoLimiter(async () => {
206 // re-push in case some of the unlocalizable / meta data changed

Callers 1

executeFunction · 0.85

Calls 10

createLoaderForTaskFunction · 0.90
createDeltaProcessorFunction · 0.90
computeProcessableDataFunction · 0.90
processRenamedKeysFunction · 0.85
getMethod · 0.65
pullMethod · 0.65
pullHintsMethod · 0.65
pushMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…