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

Function plan

packages/cli/src/cli/cmd/run/plan.ts:11–140  ·  view source on GitHub ↗
(
  input: CmdRunContext,
)

Source from the content-addressed store, hash-verified

9import { CmdRunContext } from "./_types";
10
11export default async function plan(
12 input: CmdRunContext,
13): Promise<CmdRunContext> {
14 console.log(chalk.hex(colors.orange)("[Planning]"));
15
16 let buckets = getBuckets(input.config!);
17 if (input.flags.bucket) {
18 buckets = buckets.filter((b) => input.flags.bucket!.includes(b.type));
19 }
20
21 const _sourceLocale = input.flags.sourceLocale || input.config!.locale.source;
22 if (!_sourceLocale) {
23 throw new Error(
24 `No source locale provided. Use --source-locale to specify the source locale or add it to i18n.json (locale.source)`,
25 );
26 }
27 const _targetLocales =
28 input.flags.targetLocale || input.config!.locale.targets;
29 if (!_targetLocales.length) {
30 throw new Error(
31 `No target locales provided. Use --target-locale to specify the target locales or add them to i18n.json (locale.targets)`,
32 );
33 }
34
35 return new Listr<CmdRunContext>(
36 [
37 {
38 title: "Locating content buckets",
39 task: async (ctx, task) => {
40 const bucketCount = buckets.length;
41 const bucketFilter = input.flags.bucket
42 ? ` ${chalk.dim(`(filtered by: ${chalk.hex(colors.yellow)(input.flags.bucket!.join(", "))})`)}`
43 : "";
44 task.title = `Found ${chalk.hex(colors.yellow)(bucketCount.toString())} bucket(s)${bucketFilter}`;
45 },
46 },
47 {
48 title: "Detecting locales",
49 task: async (ctx, task) => {
50 task.title = `Found ${chalk.hex(colors.yellow)(_targetLocales.length.toString())} target locale(s)`;
51 },
52 },
53 {
54 title: "Locating localizable files",
55 task: async (ctx, task) => {
56 const patterns: string[] = [];
57
58 for (const bucket of buckets) {
59 for (const bucketPath of bucket.paths) {
60 if (input.flags.file) {
61 if (
62 !input.flags.file.some(
63 (f) =>
64 bucketPath.pathPattern.includes(f) ||
65 minimatch(bucketPath.pathPattern, f),
66 )
67 ) {
68 continue;

Callers 2

triggerRetranslationFunction · 0.85
index.tsFile · 0.85

Calls 6

getBucketsFunction · 0.90
resolveOverriddenLocaleFunction · 0.85
logMethod · 0.80
toStringMethod · 0.80
runMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected