locadex 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # locadex
2
2
 
3
+ ## 0.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#397](https://github.com/generaltranslation/gt/pull/397) [`80a1395`](https://github.com/generaltranslation/gt/commit/80a13955db9ff46e5883ac8b0909ab294c63d001) Thanks [@brian-lou](https://github.com/brian-lou)! - Run translate after i18n
8
+
9
+ - Updated dependencies [[`80a1395`](https://github.com/generaltranslation/gt/commit/80a13955db9ff46e5883ac8b0909ab294c63d001)]:
10
+ - gtx-cli@1.2.28
11
+
3
12
  ## 0.1.8
4
13
 
5
14
  ### Patch Changes
package/dist/cli.js CHANGED
@@ -8,10 +8,9 @@ import './utils/shutdown.js';
8
8
  import { Command } from 'commander';
9
9
  import { readFileSync } from 'node:fs';
10
10
  import { fromPackageRoot } from './utils/getPaths.js';
11
- import { setupCommand } from './commands/setup.js';
11
+ import { autoSetupCommand, setupCommand } from './commands/setup.js';
12
12
  import { i18nCommand } from './commands/i18n.js';
13
13
  import { main } from 'gtx-cli/index';
14
- import { fixErrorsCommand } from './commands/fixErrors.js';
15
14
  const packageJson = JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'));
16
15
  const program = new Command();
17
16
  program
@@ -30,23 +29,26 @@ program
30
29
  .option('--package-manager <manager>', 'Package manager to use. (npm, pnpm, yarn_v1, yarn_v2, bun, deno)')
31
30
  .option('-y, --bypass-prompts', 'Bypass interactive prompts')
32
31
  .option('--no-telemetry', 'Disable telemetry')
32
+ .option('--no-translate', 'Disable translation step')
33
33
  .option('--app-dir <dir>', 'Relative path to the application directory', '.')
34
34
  .action(setupCommand);
35
35
  program
36
- .command('i18n')
37
- .description('Run Locadex i18n on your project')
36
+ .command('auto')
37
+ .description('Run Locadex with auto-setup on your project')
38
38
  .option('-v, --verbose', 'Verbose output')
39
39
  .option('-d, --debug', 'Debug output')
40
40
  .option('-b, --batch-size <number>', 'File batch size')
41
41
  .option('-t, --timeout <number>', 'Timeout for each file in a batch')
42
42
  .option('-c, --concurrency <number>', 'Max number of concurrent agents')
43
43
  .option('-m, --match-files <pattern>', 'Comma-separated list of glob patterns to match source files. Should be relative to root directory.')
44
+ .option('--package-manager <manager>', 'Package manager to use. (npm, pnpm, yarn_v1, yarn_v2, bun, deno)')
44
45
  .option('--no-telemetry', 'Disable telemetry')
46
+ .option('--no-translate', 'Disable translation step')
45
47
  .option('--app-dir <dir>', 'Relative path to the application directory', '.')
46
- .action(i18nCommand);
48
+ .action(autoSetupCommand);
47
49
  program
48
- .command('fix')
49
- .description('Run Locadex to validate your project and fix errors')
50
+ .command('i18n')
51
+ .description('Run Locadex i18n on your project')
50
52
  .option('-v, --verbose', 'Verbose output')
51
53
  .option('-d, --debug', 'Debug output')
52
54
  .option('-b, --batch-size <number>', 'File batch size')
@@ -54,8 +56,9 @@ program
54
56
  .option('-c, --concurrency <number>', 'Max number of concurrent agents')
55
57
  .option('-m, --match-files <pattern>', 'Comma-separated list of glob patterns to match source files. Should be relative to root directory.')
56
58
  .option('--no-telemetry', 'Disable telemetry')
59
+ .option('--no-translate', 'Disable translation step')
57
60
  .option('--app-dir <dir>', 'Relative path to the application directory', '.')
58
- .action(fixErrorsCommand);
61
+ .action(i18nCommand);
59
62
  main(program);
60
63
  program.parse();
61
64
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"/","sources":["cli.ts"],"names":[],"mappings":";AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACtD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port dotenv from 'dotenv';\n\ndotenv.config({ path: '.env' });\ndotenv.config({ path: '.env.local', override: true });\ndotenv.config({ path: '.env.production', override: true });\n\nimport './telemetry.js';\nimport './utils/shutdown.js';\nimport { Command } from 'commander';\nimport { readFileSync } from 'node:fs';\nimport { fromPackageRoot } from './utils/getPaths.js';\nimport { setupCommand } from './commands/setup.js';\nimport { i18nCommand } from './commands/i18n.js';\nimport { main } from 'gtx-cli/index';\nimport { fixErrorsCommand } from './commands/fixErrors.js';\n\nconst packageJson = JSON.parse(\n readFileSync(fromPackageRoot('package.json'), 'utf8')\n);\n\nconst program = new Command();\n\nprogram\n .name('locadex')\n .description('AI agent for internationalization')\n .version(packageJson.version);\n\nprogram\n .command('start')\n .description('Run Locadex on your project')\n .option('-v, --verbose', 'Verbose output')\n .option('-d, --debug', 'Debug output')\n .option('-b, --batch-size <number>', 'File batch size')\n .option('-t, --timeout <number>', 'Timeout for each file in a batch')\n .option('-c, --concurrency <number>', 'Max number of concurrent agents')\n .option(\n '-m, --match-files <pattern>',\n 'Comma-separated list of glob patterns to match source files. Should be relative to root directory.'\n )\n .option(\n '--package-manager <manager>',\n 'Package manager to use. (npm, pnpm, yarn_v1, yarn_v2, bun, deno)'\n )\n .option('-y, --bypass-prompts', 'Bypass interactive prompts')\n .option('--no-telemetry', 'Disable telemetry')\n .option('--app-dir <dir>', 'Relative path to the application directory', '.')\n .action(setupCommand);\n\nprogram\n .command('i18n')\n .description('Run Locadex i18n on your project')\n .option('-v, --verbose', 'Verbose output')\n .option('-d, --debug', 'Debug output')\n .option('-b, --batch-size <number>', 'File batch size')\n .option('-t, --timeout <number>', 'Timeout for each file in a batch')\n .option('-c, --concurrency <number>', 'Max number of concurrent agents')\n .option(\n '-m, --match-files <pattern>',\n 'Comma-separated list of glob patterns to match source files. Should be relative to root directory.'\n )\n .option('--no-telemetry', 'Disable telemetry')\n .option('--app-dir <dir>', 'Relative path to the application directory', '.')\n .action(i18nCommand);\n\nprogram\n .command('fix')\n .description('Run Locadex to validate your project and fix errors')\n .option('-v, --verbose', 'Verbose output')\n .option('-d, --debug', 'Debug output')\n .option('-b, --batch-size <number>', 'File batch size')\n .option('-t, --timeout <number>', 'Timeout for each file in a batch')\n .option('-c, --concurrency <number>', 'Max number of concurrent agents')\n .option(\n '-m, --match-files <pattern>',\n 'Comma-separated list of glob patterns to match source files. Should be relative to root directory.'\n )\n .option('--no-telemetry', 'Disable telemetry')\n .option('--app-dir <dir>', 'Relative path to the application directory', '.')\n .action(fixErrorsCommand);\n\nmain(program);\n\nprogram.parse();\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"/","sources":["cli.ts"],"names":[],"mappings":";AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAE3D,OAAO,gBAAgB,CAAC;AACxB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAY,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,CACtD,CAAC;AAEF,MAAM,OAAO,GAAG,IAAI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AAC,gBAAgB,EAAE,0BAA0B,CAAC;KACpD,MAAM,CAAC,iBAAiB,EAAE,4CAA4C,EAAE,GAAG,CAAC;KAC5E,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE5B,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,kCAAkC,CAAC;KAC/C,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC;KACzC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC;KACrC,MAAM,CAAC,2BAA2B,EAAE,iBAAiB,CAAC;KACtD,MAAM,CAAC,wBAAwB,EAAE,kCAAkC,CAAC;KACpE,MAAM,CAAC,4BAA4B,EAAE,iCAAiC,CAAC;KACvE,MAAM,CACL,6BAA6B,EAC7B,oGAAoG,CACrG;KACA,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC;KAC7C,MAAM,CAAC,gBAAgB,EAAE,0BAA0B,CAAC;KACpD,MAAM,CAAC,iBAAiB,EAAE,4CAA4C,EAAE,GAAG,CAAC;KAC5E,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,IAAI,CAAC,OAAO,CAAC,CAAC;AAEd,OAAO,CAAC,KAAK,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport dotenv from 'dotenv';\n\ndotenv.config({ path: '.env' });\ndotenv.config({ path: '.env.local', override: true });\ndotenv.config({ path: '.env.production', override: true });\n\nimport './telemetry.js';\nimport './utils/shutdown.js';\nimport { Command } from 'commander';\nimport { readFileSync } from 'node:fs';\nimport { fromPackageRoot } from './utils/getPaths.js';\nimport { autoSetupCommand, setupCommand } from './commands/setup.js';\nimport { i18nCommand } from './commands/i18n.js';\nimport { main } from 'gtx-cli/index';\n\nconst packageJson = JSON.parse(\n readFileSync(fromPackageRoot('package.json'), 'utf8')\n);\n\nconst program = new Command();\n\nprogram\n .name('locadex')\n .description('AI agent for internationalization')\n .version(packageJson.version);\n\nprogram\n .command('start')\n .description('Run Locadex on your project')\n .option('-v, --verbose', 'Verbose output')\n .option('-d, --debug', 'Debug output')\n .option('-b, --batch-size <number>', 'File batch size')\n .option('-t, --timeout <number>', 'Timeout for each file in a batch')\n .option('-c, --concurrency <number>', 'Max number of concurrent agents')\n .option(\n '-m, --match-files <pattern>',\n 'Comma-separated list of glob patterns to match source files. Should be relative to root directory.'\n )\n .option(\n '--package-manager <manager>',\n 'Package manager to use. (npm, pnpm, yarn_v1, yarn_v2, bun, deno)'\n )\n .option('-y, --bypass-prompts', 'Bypass interactive prompts')\n .option('--no-telemetry', 'Disable telemetry')\n .option('--no-translate', 'Disable translation step')\n .option('--app-dir <dir>', 'Relative path to the application directory', '.')\n .action(setupCommand);\n\nprogram\n .command('auto')\n .description('Run Locadex with auto-setup on your project')\n .option('-v, --verbose', 'Verbose output')\n .option('-d, --debug', 'Debug output')\n .option('-b, --batch-size <number>', 'File batch size')\n .option('-t, --timeout <number>', 'Timeout for each file in a batch')\n .option('-c, --concurrency <number>', 'Max number of concurrent agents')\n .option(\n '-m, --match-files <pattern>',\n 'Comma-separated list of glob patterns to match source files. Should be relative to root directory.'\n )\n .option(\n '--package-manager <manager>',\n 'Package manager to use. (npm, pnpm, yarn_v1, yarn_v2, bun, deno)'\n )\n .option('--no-telemetry', 'Disable telemetry')\n .option('--no-translate', 'Disable translation step')\n .option('--app-dir <dir>', 'Relative path to the application directory', '.')\n .action(autoSetupCommand);\n\nprogram\n .command('i18n')\n .description('Run Locadex i18n on your project')\n .option('-v, --verbose', 'Verbose output')\n .option('-d, --debug', 'Debug output')\n .option('-b, --batch-size <number>', 'File batch size')\n .option('-t, --timeout <number>', 'Timeout for each file in a batch')\n .option('-c, --concurrency <number>', 'Max number of concurrent agents')\n .option(\n '-m, --match-files <pattern>',\n 'Comma-separated list of glob patterns to match source files. Should be relative to root directory.'\n )\n .option('--no-telemetry', 'Disable telemetry')\n .option('--no-translate', 'Disable translation step')\n .option('--app-dir <dir>', 'Relative path to the application directory', '.')\n .action(i18nCommand);\n\nmain(program);\n\nprogram.parse();\n"]}
@@ -35,7 +35,7 @@ export async function i18nCommand(options, command) {
35
35
  }),
36
36
  },
37
37
  });
38
- await i18nTask();
38
+ await i18nTask(allOptions);
39
39
  });
40
40
  }
41
41
  //# sourceMappingURL=i18n.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sourceRoot":"/","sources":["commands/i18n.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAmB,EAAE,OAAgB;IACrE,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACnD,MAAM,UAAU,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpD,MAAM,gBAAgB,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC;IACjD,aAAa,CACX,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,EAClD,KAAK,IAAI,EAAE;QACT,MAAM,cAAc,CAAC,UAAU,CAAC,CAAC;QAEjC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAChC,cAAc,CAAC,UAAU,CAAC;YACxB,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC;YAC5D,YAAY,EAAE,OAAO;YACrB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE;YAC3C,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE;gBACP,GAAG,CAAC,UAAU,CAAC,aAAa,IAAI;oBAC9B,aAAa,EAAE,UAAU,CAAC,aAAa;yBACpC,KAAK,CAAC,GAAG,CAAC;yBACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;iBAC9B,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,WAAW,IAAI;oBAC5B,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC;iBAC/C,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,SAAS,IAAI;oBAC1B,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;iBACxC,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,OAAO,IAAI;oBACxB,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;iBACpC,CAAC;aACH;SACF,CAAC,CAAC;QACH,MAAM,QAAQ,EAAE,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { Command } from 'commander';\nimport { i18nTask } from '../tasks/i18n.js';\nimport { CliOptions } from '../types/cli.js';\nimport { withTelemetry } from '../telemetry.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { displayHeader } from '../logging/console.js';\nimport path from 'node:path';\nimport { validateConfig } from '../utils/config.js';\n\nexport async function i18nCommand(options: CliOptions, command: Command) {\n const parentOptions = command.parent?.opts() || {};\n const allOptions = { ...parentOptions, ...options };\n const telemetryEnabled = !allOptions.noTelemetry;\n withTelemetry(\n { enabled: telemetryEnabled, options: allOptions },\n async () => {\n await validateConfig(allOptions);\n\n displayHeader(telemetryEnabled);\n LocadexManager.initialize({\n rootDirectory: process.cwd(),\n appDirectory: path.resolve(process.cwd(), allOptions.appDir),\n mcpTransport: 'stdio',\n apiKey: process.env.ANTHROPIC_API_KEY || '',\n metadata: {},\n cliOptions: allOptions,\n options: {\n ...(allOptions.matchingFiles && {\n matchingFiles: allOptions.matchingFiles\n .split(',')\n .map((file) => file.trim()),\n }),\n ...(allOptions.concurrency && {\n maxConcurrency: Number(allOptions.concurrency),\n }),\n ...(allOptions.batchSize && {\n batchSize: Number(allOptions.batchSize),\n }),\n ...(allOptions.timeout && {\n timeout: Number(allOptions.timeout),\n }),\n },\n });\n await i18nTask();\n }\n );\n}\n"]}
1
+ {"version":3,"file":"i18n.js","sourceRoot":"/","sources":["commands/i18n.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAmB,EAAE,OAAgB;IACrE,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACnD,MAAM,UAAU,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpD,MAAM,gBAAgB,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC;IACjD,aAAa,CACX,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,EAClD,KAAK,IAAI,EAAE;QACT,MAAM,cAAc,CAAC,UAAU,CAAC,CAAC;QAEjC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAChC,cAAc,CAAC,UAAU,CAAC;YACxB,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC;YAC5D,YAAY,EAAE,OAAO;YACrB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE;YAC3C,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE;gBACP,GAAG,CAAC,UAAU,CAAC,aAAa,IAAI;oBAC9B,aAAa,EAAE,UAAU,CAAC,aAAa;yBACpC,KAAK,CAAC,GAAG,CAAC;yBACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;iBAC9B,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,WAAW,IAAI;oBAC5B,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC;iBAC/C,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,SAAS,IAAI;oBAC1B,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;iBACxC,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,OAAO,IAAI;oBACxB,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;iBACpC,CAAC;aACH;SACF,CAAC,CAAC;QACH,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { Command } from 'commander';\nimport { i18nTask } from '../tasks/i18n.js';\nimport { CliOptions } from '../types/cli.js';\nimport { withTelemetry } from '../telemetry.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { displayHeader } from '../logging/console.js';\nimport path from 'node:path';\nimport { validateConfig } from '../utils/config.js';\n\nexport async function i18nCommand(options: CliOptions, command: Command) {\n const parentOptions = command.parent?.opts() || {};\n const allOptions = { ...parentOptions, ...options };\n const telemetryEnabled = !allOptions.noTelemetry;\n withTelemetry(\n { enabled: telemetryEnabled, options: allOptions },\n async () => {\n await validateConfig(allOptions);\n\n displayHeader(telemetryEnabled);\n LocadexManager.initialize({\n rootDirectory: process.cwd(),\n appDirectory: path.resolve(process.cwd(), allOptions.appDir),\n mcpTransport: 'stdio',\n apiKey: process.env.ANTHROPIC_API_KEY || '',\n metadata: {},\n cliOptions: allOptions,\n options: {\n ...(allOptions.matchingFiles && {\n matchingFiles: allOptions.matchingFiles\n .split(',')\n .map((file) => file.trim()),\n }),\n ...(allOptions.concurrency && {\n maxConcurrency: Number(allOptions.concurrency),\n }),\n ...(allOptions.batchSize && {\n batchSize: Number(allOptions.batchSize),\n }),\n ...(allOptions.timeout && {\n timeout: Number(allOptions.timeout),\n }),\n },\n });\n await i18nTask(allOptions);\n }\n );\n}\n"]}
@@ -4,4 +4,8 @@ export declare function setupCommand(options: CliOptions & {
4
4
  packageManager?: string;
5
5
  bypassPrompts?: boolean;
6
6
  }, command: Command): Promise<void>;
7
+ export declare function autoSetupCommand(options: CliOptions & {
8
+ packageManager?: string;
9
+ bypassPrompts?: boolean;
10
+ }, command: Command): Promise<void>;
7
11
  //# sourceMappingURL=setup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["commands/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO7C,wBAAsB,YAAY,CAChC,OAAO,EAAE,UAAU,GAAG;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,EACD,OAAO,EAAE,OAAO,iBAsCjB"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["commands/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO7C,wBAAsB,YAAY,CAChC,OAAO,EAAE,UAAU,GAAG;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,EACD,OAAO,EAAE,OAAO,iBA2CjB;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,UAAU,GAAG;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,EACD,OAAO,EAAE,OAAO,iBA2CjB"}
@@ -35,7 +35,41 @@ export async function setupCommand(options, command) {
35
35
  }),
36
36
  },
37
37
  });
38
- await setupTask(!!allOptions.bypassPrompts, allOptions.packageManager);
38
+ await setupTask(allOptions, false, !!allOptions.bypassPrompts, allOptions.packageManager);
39
+ });
40
+ }
41
+ export async function autoSetupCommand(options, command) {
42
+ const parentOptions = command.parent?.opts() || {};
43
+ const allOptions = { ...parentOptions, ...options };
44
+ const telemetryEnabled = !allOptions.noTelemetry;
45
+ withTelemetry({ enabled: telemetryEnabled, options: allOptions }, async () => {
46
+ await validateConfig(allOptions);
47
+ displayHeader(telemetryEnabled);
48
+ LocadexManager.initialize({
49
+ rootDirectory: process.cwd(),
50
+ appDirectory: path.resolve(process.cwd(), allOptions.appDir),
51
+ mcpTransport: 'stdio',
52
+ apiKey: process.env.ANTHROPIC_API_KEY || '',
53
+ metadata: {},
54
+ cliOptions: allOptions,
55
+ options: {
56
+ ...(allOptions.matchingFiles && {
57
+ matchingFiles: allOptions.matchingFiles
58
+ .split(',')
59
+ .map((file) => file.trim()),
60
+ }),
61
+ ...(allOptions.concurrency && {
62
+ maxConcurrency: Number(allOptions.concurrency),
63
+ }),
64
+ ...(allOptions.batchSize && {
65
+ batchSize: Number(allOptions.batchSize),
66
+ }),
67
+ ...(allOptions.timeout && {
68
+ timeout: Number(allOptions.timeout),
69
+ }),
70
+ },
71
+ });
72
+ await setupTask(allOptions, true, !!allOptions.bypassPrompts, allOptions.packageManager);
39
73
  });
40
74
  }
41
75
  //# sourceMappingURL=setup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","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AAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;iBAC9B,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,WAAW,IAAI;oBAC5B,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC;iBAC/C,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,SAAS,IAAI;oBAC1B,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;iBACxC,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,OAAO,IAAI;oBACxB,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;iBACpC,CAAC;aACH;SACF,CAAC,CAAC;QACH,MAAM,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IACzE,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { Command } from 'commander';\nimport { setupTask } from '../tasks/setup.js';\nimport { CliOptions } from '../types/cli.js';\nimport { withTelemetry } from '../telemetry.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { displayHeader } from '../logging/console.js';\nimport path from 'node:path';\nimport { validateConfig } from '../utils/config.js';\n\nexport async function setupCommand(\n options: CliOptions & {\n packageManager?: string;\n bypassPrompts?: boolean;\n },\n command: Command\n) {\n const parentOptions = command.parent?.opts() || {};\n const allOptions = { ...parentOptions, ...options };\n const telemetryEnabled = !allOptions.noTelemetry;\n withTelemetry(\n { enabled: telemetryEnabled, options: allOptions },\n async () => {\n await validateConfig(allOptions);\n\n displayHeader(telemetryEnabled);\n LocadexManager.initialize({\n rootDirectory: process.cwd(),\n appDirectory: path.resolve(process.cwd(), allOptions.appDir),\n mcpTransport: 'stdio',\n apiKey: process.env.ANTHROPIC_API_KEY || '',\n metadata: {},\n cliOptions: allOptions,\n options: {\n ...(allOptions.matchingFiles && {\n matchingFiles: allOptions.matchingFiles\n .split(',')\n .map((file) => file.trim()),\n }),\n ...(allOptions.concurrency && {\n maxConcurrency: Number(allOptions.concurrency),\n }),\n ...(allOptions.batchSize && {\n batchSize: Number(allOptions.batchSize),\n }),\n ...(allOptions.timeout && {\n timeout: Number(allOptions.timeout),\n }),\n },\n });\n await setupTask(!!allOptions.bypassPrompts, allOptions.packageManager);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"setup.js","sourceRoot":"/","sources":["commands/setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAGC,EACD,OAAgB;IAEhB,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACnD,MAAM,UAAU,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpD,MAAM,gBAAgB,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC;IACjD,aAAa,CACX,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,EAClD,KAAK,IAAI,EAAE;QACT,MAAM,cAAc,CAAC,UAAU,CAAC,CAAC;QAEjC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAChC,cAAc,CAAC,UAAU,CAAC;YACxB,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC;YAC5D,YAAY,EAAE,OAAO;YACrB,MAAM,EAAE,OAAO,CA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a,CAAC,gBAAgB,CAAC,CAAC;QAChC,cAAc,CAAC,UAAU,CAAC;YACxB,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC;YAC5D,YAAY,EAAE,OAAO;YACrB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE;YAC3C,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE;gBACP,GAAG,CAAC,UAAU,CAAC,aAAa,IAAI;oBAC9B,aAAa,EAAE,UAAU,CAAC,aAAa;yBACpC,KAAK,CAAC,GAAG,CAAC;yBACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;iBAC9B,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,WAAW,IAAI;oBAC5B,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC;iBAC/C,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,SAAS,IAAI;oBAC1B,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;iBACxC,CAAC;gBACF,GAAG,CAAC,UAAU,CAAC,OAAO,IAAI;oBACxB,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;iBACpC,CAAC;aACH;SACF,CAAC,CAAC;QACH,MAAM,SAAS,CACb,UAAU,EACV,IAAI,EACJ,CAAC,CAAC,UAAU,CAAC,aAAa,EAC1B,UAAU,CAAC,cAAc,CAC1B,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { Command } from 'commander';\nimport { setupTask } from '../tasks/setup.js';\nimport { CliOptions } from '../types/cli.js';\nimport { withTelemetry } from '../telemetry.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { displayHeader } from '../logging/console.js';\nimport path from 'node:path';\nimport { validateConfig } from '../utils/config.js';\n\nexport async function setupCommand(\n options: CliOptions & {\n packageManager?: string;\n bypassPrompts?: boolean;\n },\n command: Command\n) {\n const parentOptions = command.parent?.opts() || {};\n const allOptions = { ...parentOptions, ...options };\n const telemetryEnabled = !allOptions.noTelemetry;\n withTelemetry(\n { enabled: telemetryEnabled, options: allOptions },\n async () => {\n await validateConfig(allOptions);\n\n displayHeader(telemetryEnabled);\n LocadexManager.initialize({\n rootDirectory: process.cwd(),\n appDirectory: path.resolve(process.cwd(), allOptions.appDir),\n mcpTransport: 'stdio',\n apiKey: process.env.ANTHROPIC_API_KEY || '',\n metadata: {},\n cliOptions: allOptions,\n options: {\n ...(allOptions.matchingFiles && {\n matchingFiles: allOptions.matchingFiles\n .split(',')\n .map((file) => file.trim()),\n }),\n ...(allOptions.concurrency && {\n maxConcurrency: Number(allOptions.concurrency),\n }),\n ...(allOptions.batchSize && {\n batchSize: Number(allOptions.batchSize),\n }),\n ...(allOptions.timeout && {\n timeout: Number(allOptions.timeout),\n }),\n },\n });\n await setupTask(\n allOptions,\n false,\n !!allOptions.bypassPrompts,\n allOptions.packageManager\n );\n }\n );\n}\n\nexport async function autoSetupCommand(\n options: CliOptions & {\n packageManager?: string;\n bypassPrompts?: boolean;\n },\n command: Command\n) {\n const parentOptions = command.parent?.opts() || {};\n const allOptions = { ...parentOptions, ...options };\n const telemetryEnabled = !allOptions.noTelemetry;\n withTelemetry(\n { enabled: telemetryEnabled, options: allOptions },\n async () => {\n await validateConfig(allOptions);\n\n displayHeader(telemetryEnabled);\n LocadexManager.initialize({\n rootDirectory: process.cwd(),\n appDirectory: path.resolve(process.cwd(), allOptions.appDir),\n mcpTransport: 'stdio',\n apiKey: process.env.ANTHROPIC_API_KEY || '',\n metadata: {},\n cliOptions: allOptions,\n options: {\n ...(allOptions.matchingFiles && {\n matchingFiles: allOptions.matchingFiles\n .split(',')\n .map((file) => file.trim()),\n }),\n ...(allOptions.concurrency && {\n maxConcurrency: Number(allOptions.concurrency),\n }),\n ...(allOptions.batchSize && {\n batchSize: Number(allOptions.batchSize),\n }),\n ...(allOptions.timeout && {\n timeout: Number(allOptions.timeout),\n }),\n },\n });\n await setupTask(\n allOptions,\n true,\n !!allOptions.bypassPrompts,\n allOptions.packageManager\n );\n }\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"console.d.ts","sourceRoot":"/","sources":["logging/console.ts"],"names":[],"mappings":"AAmBA,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,QAEtC;AACD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,QAEzC;AACD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,QAEvC;AACD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,QAEzC;AACD,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,QAEtC;AACD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,QAEzC;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,iBAGpD;AAGD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,QAE3C;AACD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,QAEzC;AAGD,wBAAgB,aAAa,CAAC,gBAAgB,EAAE,OAAO,QAItD;AA6BD,wBAAgB,aAAa,CAAC,SAAS,GAAE,MAAM,GAAG,OAAiB,0CAElE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,2CAE9C;AAGD,wBAAsB,UAAU,CAAC,EAC/B,OAAO,EACP,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC;CAChD,4BAkBA;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,EACpC,OAAO,EACP,OAAO,EACP,YAAY,GACb,EAAE;IACD,O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AY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,6BAYA;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM;;;;EAE/C"}
@@ -53,7 +53,8 @@ function displayInitializingText(telemetryEnabled) {
53
53
  // eslint-disable-next-line no-console
54
54
  console.log(`\n${chalk.bold.blue('General Translation, Inc.')}
55
55
  ${chalk.dim('https://generaltranslation.com/docs')}
56
- ${telemetryEnabled ? chalk.dim('\nLocadex is configured to collect anonymous telemetry data. You can opt out by running with the --no-telemetry flag.') : ''}
56
+ ${telemetryEnabled ? chalk.dim('\nLocadex is configured to collect anonymous telemetry data. You can opt out by running with the --no-telemetry flag.\n') : ''}
57
+ Locadex is in open beta and may make mistakes. Please report any bugs or issues to https://github.com/generaltranslation/gt/issues.
57
58
  `);
58
59
  }
59
60
  // Spinner functionality
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","sourceRoot":"/","sources":["logging/console.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,OAAO,EACP,KAAK,EACL,KAAK,EACL,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,MAAM,EACN,WAAW,EACX,OAAO,EACP,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,0BAA0B;AAC1B,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AACD,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACr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Y,EAAE,YAAY;KAC3B,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,aAAa,CAAC,CAAC;QACtB,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {\n log,\n spinner,\n intro,\n outro,\n text,\n select,\n confirm,\n isCancel,\n cancel,\n multiselect,\n taskLog,\n progress,\n} from '@clack/prompts';\nimport chalk from 'chalk';\nimport { getLocadexVersion } from '../utils/getPaths.js';\nimport { exit } from '../utils/shutdown.js';\n\n// Basic logging functions\nexport function logInfo(message: string) {\n log.info(message);\n}\nexport function logWarning(message: string) {\n log.warn(message);\n}\nexport function logError(message: string) {\n log.error(message);\n}\nexport function logSuccess(message: string) {\n log.success(message);\n}\nexport function logStep(message: string) {\n log.step(message);\n}\nexport function logMessage(message: string) {\n log.message(message, { symbol: chalk.cyan('~') });\n}\n\nexport async function logErrorAndExit(message: string) {\n log.error(message);\n await exit(1);\n}\n\n// Clack prompts\nexport function startCommand(message: string) {\n intro(chalk.cyan(message));\n}\nexport function endCommand(message: string) {\n outro(chalk.cyan(message));\n}\n\n// GT specific logging\nexport function displayHeader(telemetryEnabled: boolean) {\n displayAsciiTitle();\n displayInitializingText(telemetryEnabled);\n startCommand(chalk.cyan(`Locadex v${getLocadexVersion()}`));\n}\n\nfunction displayAsciiTitle() {\n // eslint-disable-next-line no-console\n console.log(\n chalk.cyan(\n `\\n ,ad8888ba, 888888888888 \n d8\"' \\`\"8b 88 \nd8' 88 \n88 88 \n88 88888 88 \nY8, 88 88 \n Y8a. .a88 88 \n \\`\"Y88888P\" 88 `\n )\n );\n}\n\nfunction displayInitializingText(telemetryEnabled: boolean) {\n // eslint-disable-next-line no-console\n console.log(\n `\\n${chalk.bold.blue('General Translation, Inc.')}\n${chalk.dim('https://generaltranslation.com/docs')}\n${telemetryEnabled ? chalk.dim('\\nLocadex is configured to collect anonymous telemetry data. You can opt out by running with the --no-telemetry flag.') : ''}\n`\n );\n}\n\n// Spinner functionality\nexport function createSpinner(indicator: 'dots' | 'timer' = 'timer') {\n return spinner({ indicator });\n}\n\nexport function createProgressBar(total: number) {\n return progress({ max: total });\n}\n\n// Input prompts\nexport async function promptText({\n message,\n defaultValue,\n validate,\n}: {\n message: string;\n defaultValue?: string;\n validate?: (value: string) => boolean | string;\n}) {\n const result = await text({\n message,\n placeholder: defaultValue,\n validate: validate\n ? (value) => {\n const validation = validate(value || '');\n return validation === true ? undefined : validation.toString();\n }\n : undefined,\n });\n\n if (isCancel(result)) {\n cancel('Operation cancelled');\n await exit(0);\n }\n\n return result;\n}\n\nexport async function promptSelect<T>({\n message,\n options,\n defaultValue,\n}: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n defaultValue?: T;\n}) {\n // Convert options to the format expected by clack\n const clackOptions = options.map((opt) => ({\n value: opt.value,\n label: opt.label,\n hint: opt.hint,\n }));\n\n const result = await select({\n message,\n options: clackOptions as any,\n initialValue: defaultValue,\n });\n\n if (isCancel(result)) {\n cancel('Operation cancelled');\n await exit(0);\n }\n\n return result as T;\n}\n\nexport async function promptMultiSelect<T extends string>({\n message,\n options,\n required = true,\n}: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n required?: boolean;\n}) {\n // Convert options to the format expected by clack\n const clackOptions = options.map((opt) => ({\n value: opt.value,\n label: opt.label,\n hint: opt.hint,\n }));\n\n const result = await multiselect({\n message,\n options: clackOptions as any,\n required,\n });\n\n if (isCancel(result)) {\n cancel('Operation cancelled');\n await exit(0);\n }\n\n return result as Array<T>;\n}\n\nexport async function promptConfirm({\n message,\n defaultValue = true,\n cancelMessage = 'Operation cancelled',\n}: {\n message: string;\n defaultValue?: boolean;\n cancelMessage?: string;\n}) {\n const result = await confirm({\n message,\n initialValue: defaultValue,\n });\n\n if (isCancel(result)) {\n cancel(cancelMessage);\n await exit(0);\n }\n\n return result;\n}\n\nexport function createTaskLogger(message: string) {\n return taskLog({ title: message });\n}\n"]}
1
+ {"version":3,"file":"console.js","sourceRoot":"/","sources":["logging/console.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,OAAO,EACP,KAAK,EACL,KAAK,EACL,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,MAAM,EACN,WAAW,EACX,OAAO,EACP,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,0BAA0B;AAC1B,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AACD,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC;AACD,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OA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\n taskLog,\n progress,\n} from '@clack/prompts';\nimport chalk from 'chalk';\nimport { getLocadexVersion } from '../utils/getPaths.js';\nimport { exit } from '../utils/shutdown.js';\n\n// Basic logging functions\nexport function logInfo(message: string) {\n log.info(message);\n}\nexport function logWarning(message: string) {\n log.warn(message);\n}\nexport function logError(message: string) {\n log.error(message);\n}\nexport function logSuccess(message: string) {\n log.success(message);\n}\nexport function logStep(message: string) {\n log.step(message);\n}\nexport function logMessage(message: string) {\n log.message(message, { symbol: chalk.cyan('~') });\n}\n\nexport async function logErrorAndExit(message: string) {\n log.error(message);\n await exit(1);\n}\n\n// Clack prompts\nexport function startCommand(message: string) {\n intro(chalk.cyan(message));\n}\nexport function endCommand(message: string) {\n outro(chalk.cyan(message));\n}\n\n// GT specific logging\nexport function displayHeader(telemetryEnabled: boolean) {\n displayAsciiTitle();\n displayInitializingText(telemetryEnabled);\n startCommand(chalk.cyan(`Locadex v${getLocadexVersion()}`));\n}\n\nfunction displayAsciiTitle() {\n // eslint-disable-next-line no-console\n console.log(\n chalk.cyan(\n `\\n ,ad8888ba, 888888888888 \n d8\"' \\`\"8b 88 \nd8' 88 \n88 88 \n88 88888 88 \nY8, 88 88 \n Y8a. .a88 88 \n \\`\"Y88888P\" 88 `\n )\n );\n}\n\nfunction displayInitializingText(telemetryEnabled: boolean) {\n // eslint-disable-next-line no-console\n console.log(\n `\\n${chalk.bold.blue('General Translation, Inc.')}\n${chalk.dim('https://generaltranslation.com/docs')}\n${telemetryEnabled ? chalk.dim('\\nLocadex is configured to collect anonymous telemetry data. You can opt out by running with the --no-telemetry flag.\\n') : ''}\nLocadex is in open beta and may make mistakes. Please report any bugs or issues to https://github.com/generaltranslation/gt/issues.\n`\n );\n}\n\n// Spinner functionality\nexport function createSpinner(indicator: 'dots' | 'timer' = 'timer') {\n return spinner({ indicator });\n}\n\nexport function createProgressBar(total: number) {\n return progress({ max: total });\n}\n\n// Input prompts\nexport async function promptText({\n message,\n defaultValue,\n validate,\n}: {\n message: string;\n defaultValue?: string;\n validate?: (value: string) => boolean | string;\n}) {\n const result = await text({\n message,\n placeholder: defaultValue,\n validate: validate\n ? (value) => {\n const validation = validate(value || '');\n return validation === true ? undefined : validation.toString();\n }\n : undefined,\n });\n\n if (isCancel(result)) {\n cancel('Operation cancelled');\n await exit(0);\n }\n\n return result;\n}\n\nexport async function promptSelect<T>({\n message,\n options,\n defaultValue,\n}: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n defaultValue?: T;\n}) {\n // Convert options to the format expected by clack\n const clackOptions = options.map((opt) => ({\n value: opt.value,\n label: opt.label,\n hint: opt.hint,\n }));\n\n const result = await select({\n message,\n options: clackOptions as any,\n initialValue: defaultValue,\n });\n\n if (isCancel(result)) {\n cancel('Operation cancelled');\n await exit(0);\n }\n\n return result as T;\n}\n\nexport async function promptMultiSelect<T extends string>({\n message,\n options,\n required = true,\n}: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n required?: boolean;\n}) {\n // Convert options to the format expected by clack\n const clackOptions = options.map((opt) => ({\n value: opt.value,\n label: opt.label,\n hint: opt.hint,\n }));\n\n const result = await multiselect({\n message,\n options: clackOptions as any,\n required,\n });\n\n if (isCancel(result)) {\n cancel('Operation cancelled');\n await exit(0);\n }\n\n return result as Array<T>;\n}\n\nexport async function promptConfirm({\n message,\n defaultValue = true,\n cancelMessage = 'Operation cancelled',\n}: {\n message: string;\n defaultValue?: boolean;\n cancelMessage?: string;\n}) {\n const result = await confirm({\n message,\n initialValue: defaultValue,\n });\n\n if (isCancel(result)) {\n cancel(cancelMessage);\n await exit(0);\n }\n\n return result;\n}\n\nexport function createTaskLogger(message: string) {\n return taskLog({ title: message });\n}\n"]}
@@ -60,8 +60,11 @@ Your new task is to fix any errors that were introduced by your previous impleme
60
60
  - These guides provide additional knowledge about how to internationalize the content.
61
61
  - NEVER move content to a different file. All content MUST remain in the same file where it came from.
62
62
  - NEVER CREATE OR DELETE ANY FILES (especially .bak files)
63
+ - YOU MAY NOT RUN ANY COMMANDS THAT ARE NOT LISTED BELOW:
64
+ - 'locadex validate'
65
+ - 'tsc --noEmit'
63
66
 
64
- To run the gt-next validator, run the following command from the app root:
67
+ To run the gt-next validator, run the following command from the app root directory:
65
68
  'locadex validate' (global command)
66
69
  The app root is: "${appDirectory}"
67
70
 
@@ -1 +1 @@
1
- {"version":3,"file":"fixErrors.js","sourceRoot":"/","sources":["tasks/fixErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAC7C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,uCAAuC;IACvC,MAAM,oBAAoB,CAAC,2BAA2B,EAAE,mBAAmB,CAAC,CAAC;IAE7E,mCAAmC;IACnC,MAAM,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;IAE3E,MAAM,CAAC,iBAAiB,EAAE,CAAC;IAC3B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,YAAY,CAAC,GAAG,CACpB,SAAS,EACT;YACE,QAAQ,EAAE,GAAG;YACb,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,CAAC;SACd,EACD,EAAE,CACH,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,oBAAoB,YAAY,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,YAAY,CAAC,cAAc,EAAE,CAAC;QAC9B,MAAM,CAAC,YAAY,CACjB,gDAAgD,KAAK,EAAE,CACxD,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,OAAO;IACT,CAAC;IACD,YAAY,CAAC,cAAc,EAAE,CAAC;IAC9B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,oDAAoD;AAEpD,SAAS,YAAY,CAAC,YAAoB;IACxC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;oBAyBG,YAAY;;;;EAI9B,YAAY;;;;;;;;;CASb,CAAC;IAEA,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { allMcpPrompt } from '../prompts/system.js';\nimport { exit } from '../utils/shutdown.js';\nimport { logger } from '../logging/logger.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { installGlobalPackage } from '../utils/packages/installPackage.js';\n\nexport async function fixErrorsTask() {\n const manager = LocadexManager.getInstance();\n const reports: string[] = [];\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n\n // Create a clean agent for cleanup\n const cleanupAgent = manager.createSingleAgent('claude_cleanup_agent', {});\n\n logger.initializeSpinner();\n logger.spinner.start('Fixing errors...');\n const fixPrompt = getFixPrompt(manager.appDirectory);\n try {\n await cleanupAgent.run(\n fixPrompt,\n {\n maxTurns: 200,\n timeoutSec: 300,\n maxRetries: 2,\n },\n {}\n );\n reports.push(`## Fixed errors\\n${cleanupAgent.generateReport()}`);\n } catch (error) {\n cleanupAgent.aggregateStats();\n logger.debugMessage(\n `[claude_cleanup_agent] Fixing errors failed: ${error}`\n );\n manager.stats.recordTelemetry(false);\n outro(chalk.red('❌ Locadex i18n failed!'));\n await exit(1);\n return;\n }\n cleanupAgent.aggregateStats();\n logger.spinner.stop('Fixed errors');\n return reports;\n}\n\n// check (dry run and ts check) should be at the end\n\nfunction getFixPrompt(appDirectory: string) {\n const prompt = `# Task: Fix internationalization errors in the project.\n\n## INSTRUCTIONS\n\nPreviously, you helped me internationalize a set of files in this project.\nYour new task is to fix any errors that were introduced by your previous implementation.\n\n## Steps:\n1. Run the gt-next validator.\n2. Fix all errors output by the gt-next validator.\n3. Repeat steps 1-2 until there are no more errors, or until you believe that you have fixed all errors.\n\n## RULES:\n- ONLY modify files that are relevant to the internationalization of the project.\n- ONLY fix errors that result from your current or previous implementation.\n- Resolve unused imports from 'gt-next'. \n - In particular, if a file contains user-facing content that should be internationalized and is not, you should internationalize it.\n- Resolve missing imports from 'gt-next'. If a file is missing an import from 'gt-next', add it.\n- ALWAYS adhere to the guides provided via the 'mcp__locadex__' tools.\n - These guides provide additional knowledge about how to internationalize the content.\n- NEVER move content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR DELETE ANY FILES (especially .bak files)\n\nTo run the gt-next validator, run the following command from the app root:\n'locadex validate' (global command)\nThe app root is: \"${appDirectory}\"\n\n## MCP TOOLS\n\n${allMcpPrompt}\n\n## Final output\n- When you are done, please return a brief summary of the files you modified, following this format.\n- **DO NOT** include any other text in your response. \n- If there were issues with some files, please include the issues in the list of changes for that file.\n\n[file 1 path]\n- List of changes to file 1\n`;\n\n return prompt;\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CAAC;QACf,YAAY,CAAC,cAAc,EAAE,CAAC;QAC9B,MAAM,CAAC,YAAY,CACjB,gDAAgD,KAAK,EAAE,CACxD,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,OAAO;IACT,CAAC;IACD,YAAY,CAAC,cAAc,EAAE,CAAC;IAC9B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,oDAAoD;AAEpD,SAAS,YAAY,CAAC,YAAoB;IACxC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA4BG,YAAY;;;;EAI9B,YAAY;;;;;;;;;CASb,CAAC;IAEA,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { allMcpPrompt } from '../prompts/system.js';\nimport { exit } from '../utils/shutdown.js';\nimport { logger } from '../logging/logger.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { installGlobalPackage } from '../utils/packages/installPackage.js';\n\nexport async function fixErrorsTask() {\n const manager = LocadexManager.getInstance();\n const reports: string[] = [];\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n\n // Create a clean agent for cleanup\n const cleanupAgent = manager.createSingleAgent('claude_cleanup_agent', {});\n\n logger.initializeSpinner();\n logger.spinner.start('Fixing errors...');\n const fixPrompt = getFixPrompt(manager.appDirectory);\n try {\n await cleanupAgent.run(\n fixPrompt,\n {\n maxTurns: 200,\n timeoutSec: 300,\n maxRetries: 2,\n },\n {}\n );\n reports.push(`## Fixed errors\\n${cleanupAgent.generateReport()}`);\n } catch (error) {\n cleanupAgent.aggregateStats();\n logger.debugMessage(\n `[claude_cleanup_agent] Fixing errors failed: ${error}`\n );\n manager.stats.recordTelemetry(false);\n outro(chalk.red('❌ Locadex i18n failed!'));\n await exit(1);\n return;\n }\n cleanupAgent.aggregateStats();\n logger.spinner.stop('Fixed errors');\n return reports;\n}\n\n// check (dry run and ts check) should be at the end\n\nfunction getFixPrompt(appDirectory: string) {\n const prompt = `# Task: Fix internationalization errors in the project.\n\n## INSTRUCTIONS\n\nPreviously, you helped me internationalize a set of files in this project.\nYour new task is to fix any errors that were introduced by your previous implementation.\n\n## Steps:\n1. Run the gt-next validator.\n2. Fix all errors output by the gt-next validator.\n3. Repeat steps 1-2 until there are no more errors, or until you believe that you have fixed all errors.\n\n## RULES:\n- ONLY modify files that are relevant to the internationalization of the project.\n- ONLY fix errors that result from your current or previous implementation.\n- Resolve unused imports from 'gt-next'. \n - In particular, if a file contains user-facing content that should be internationalized and is not, you should internationalize it.\n- Resolve missing imports from 'gt-next'. If a file is missing an import from 'gt-next', add it.\n- ALWAYS adhere to the guides provided via the 'mcp__locadex__' tools.\n - These guides provide additional knowledge about how to internationalize the content.\n- NEVER move content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR DELETE ANY FILES (especially .bak files)\n- YOU MAY NOT RUN ANY COMMANDS THAT ARE NOT LISTED BELOW:\n - 'locadex validate'\n - 'tsc --noEmit'\n\nTo run the gt-next validator, run the following command from the app root directory:\n'locadex validate' (global command)\nThe app root is: \"${appDirectory}\"\n\n## MCP TOOLS\n\n${allMcpPrompt}\n\n## Final output\n- When you are done, please return a brief summary of the files you modified, following this format.\n- **DO NOT** include any other text in your response. \n- If there were issues with some files, please include the issues in the list of changes for that file.\n\n[file 1 path]\n- List of changes to file 1\n`;\n\n return prompt;\n}\n"]}
@@ -1,2 +1,7 @@
1
- export declare function i18nTask(): Promise<void>;
1
+ import { CliOptions } from '../types/cli.js';
2
+ /**
3
+ * Run Locadex i18n on the project
4
+ * This task requires no human intervention and is safe to run in CI/CD pipelines.
5
+ */
6
+ export declare function i18nTask(cliOptions: CliOptions): Promise<void>;
2
7
  //# sourceMappingURL=i18n.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"/","sources":["tasks/i18n.ts"],"names":[],"mappings":"AA4BA,wBAAsB,QAAQ,kBAoM7B"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"/","sources":["tasks/i18n.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,UAAU,EAAE,UAAU,iBAiNpD"}
@@ -20,7 +20,11 @@ import { fixErrorsTask } from './fixErrors.js';
20
20
  import { getLocadexVersion } from '../utils/getPaths.js';
21
21
  import { execFunction } from '../utils/exec.js';
22
22
  import { isGTAuthConfigured } from '../utils/config.js';
23
- export async function i18nTask() {
23
+ /**
24
+ * Run Locadex i18n on the project
25
+ * This task requires no human intervention and is safe to run in CI/CD pipelines.
26
+ */
27
+ export async function i18nTask(cliOptions) {
24
28
  const manager = LocadexManager.getInstance();
25
29
  // have to use the package.json from the appDir
26
30
  const packageJson = await getPackageJson(manager.appDirectory);
@@ -135,31 +139,36 @@ ${reports.join('\n')}`;
135
139
  deleteAddedFiles([path.relative(manager.rootDirectory, manager.locadexDirectory)], ['dictionary.json', 'gt.config.json', 'locadex.yml']);
136
140
  cleanupOnExit();
137
141
  // Run translate cmd
138
- if (isGTAuthConfigured()) {
142
+ if (isGTAuthConfigured(manager.appDirectory) && !cliOptions.noTranslate) {
139
143
  try {
140
- await execFunction('locadex', ['translate'], false, manager.appDirectory);
141
- logger.step(`Translations generated!`);
144
+ logger.initializeSpinner();
145
+ logger.spinner.start('Running locadex translate...');
146
+ await execFunction('locadex', ['translate'], false, manager.appDirectory, manager.getAgentAbortController());
147
+ logger.spinner.stop('Translations generated!');
148
+ }
149
+ catch (error) {
150
+ logger.spinner.stop('Translations failed!');
151
+ logger.error(`Error running 'locadex translate': ${error.message}`);
142
152
  }
143
- catch (error) { }
144
153
  }
145
154
  else {
146
- logger.step(`No GT_API_KEY or GT_PROJECT_ID found. Skipping translation...`);
155
+ logger.step(`No GT_API_KEY or GT_PROJECT_ID found. Skipping translation step...`);
147
156
  }
148
157
  outro(chalk.green('✅ Locadex i18n complete!'));
149
158
  await exit(0);
150
159
  }
151
160
  function cleanupOnExit() {
152
161
  const manager = LocadexManager.getInstance();
153
- logger.info(chalk.dim(`Total Cost: $${manager.stats.getStats().totalCost.toFixed(2)}
154
- Total wall time: ${Math.round((Date.now() - manager.stats.getStats().startTime) / 1000)}s
155
- Total files processed: ${manager.stats.getStats().processedFiles}`));
162
+ logger.info(chalk.dim(`Locadex Cost: $${manager.stats.getStats().totalCost.toFixed(2)}
163
+ Locadex wall time: ${Math.round((Date.now() - manager.stats.getStats().startTime) / 1000)}s
164
+ Locadex files processed: ${manager.stats.getStats().processedFiles}`));
156
165
  const finalStats = manager.stats.getStats();
157
166
  // Record telemetry for final stats
158
167
  manager.stats.recordTelemetry(true);
159
- logger.verboseMessage(`Total input tokens: ${finalStats.inputTokens}
160
- Total cached input tokens: ${finalStats.cachedInputTokens}
161
- Total output tokens: ${finalStats.outputTokens}
162
- Total turns: ${finalStats.turns}`);
168
+ logger.verboseMessage(`Locadex input tokens: ${finalStats.inputTokens}
169
+ Locadex cached input tokens: ${finalStats.cachedInputTokens}
170
+ Locadex output tokens: ${finalStats.outputTokens}
171
+ Locadex turns: ${finalStats.turns}`);
163
172
  }
164
173
  function getPrompt({ targetFile, dependencyFiles, dependentFiles, }) {
165
174
  const prompt = `# Task: Internationalize the target file(s) using gt-next.
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sourceRoot":"/","sources":["tasks/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAA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","sourcesContent":["import { createSpinner } from '../logging/console.js';\nimport { allMcpPrompt } from '../prompts/system.js';\nimport { exit } from '../utils/shutdown.js';\nimport { logger } from '../logging/logger.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport {\n addFilesToManager,\n markFileAsEdited,\n markFileAsInProgress,\n} from '../utils/dag/getFiles.js';\nimport { runParallelProcessing, TaskProcessor } from './concurrency.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { appendFileSync } from 'node:fs';\nimport { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';\nimport path from 'node:path';\nimport { updateLockfile, cleanupLockfile } from '../utils/lockfile.js';\nimport { extractFiles } from '../utils/dag/extractFiles.js';\nimport { Dag } from '../utils/dag/createDag.js';\nimport { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';\nimport { deleteAddedFiles } from '../utils/fs/git.js';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { installGlobalPackage } from '../utils/packages/installPackage.js';\nimport { fixErrorsTask } from './fixErrors.js';\nimport { getLocadexVersion } from '../utils/getPaths.js';\nimport { execFunction } from '../utils/exec.js';\nimport { isGTAuthConfigured } from '../utils/config.js';\n\nexport async function i18nTask() {\n const manager = LocadexManager.getInstance();\n // have to use the package.json from the appDir\n const packageJson = await getPackageJson(manager.appDirectory);\n const isUsingGTNext = packageJson\n ? isPackageInstalled('gt-next', packageJson)\n : false;\n if (!isUsingGTNext) {\n logger.error(\n `gt-next not detected in ${manager.appDirectory}. Please specify the correct app directory with the --app-dir flag, or ensure that gt-next is correctly installed in the project.`\n );\n await exit(1);\n }\n\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n // Install locadex if not installed\n await installGlobalPackage('locadex', getLocadexVersion());\n\n logger.debugMessage('App directory: ' + manager.appDirectory);\n logger.debugMessage('Root directory: ' + manager.rootDirectory);\n\n // Init message\n const spinner = createSpinner();\n spinner.start('Initializing Locadex...');\n\n const { files, dag } = extractFiles(manager);\n\n if (files.length === 0) {\n spinner.stop('No files have changed since last run');\n outro(chalk.green('✅ Locadex i18n complete - no changes detected!'));\n await exit(0);\n }\n\n const filesStateFilePath = manager.getFilesStateFilePath();\n const concurrency = manager.getMaxConcurrency();\n const batchSize = manager.getBatchSize();\n\n // Create the list of files (aka tasks) to process\n const taskQueue = Array.from(files);\n\n // Add files to manager\n const stateFilePath = addFilesToManager(filesStateFilePath, taskQueue);\n spinner.stop('Locadex initialized');\n\n logger.verboseMessage(`Processing ${files.length} modified files`);\n logger.debugMessage(`Track progress here: ${stateFilePath}`);\n logger.debugMessage(`Order:\\n${taskQueue.join('\\n')}`);\n\n logger.message(`Using ${concurrency} concurrent agents`);\n logger.initializeProgressBar(taskQueue.length);\n\n const fileProcessingStartTime = Date.now();\n logger.progressBar.start(`Processing ${taskQueue.length} files...`);\n\n // Shared reports array for collecting results\n const reports: string[] = [];\n\n // Create i18n task processor\n const i18nProcessor: TaskProcessor<\n string,\n {\n dag: Dag;\n files: string[];\n filesStateFilePath: string;\n }\n > = {\n preProcess: async (files, context) => {\n const { dag, filesStateFilePath } = context;\n logger.debugMessage(`Files: ${files.join(', ')}`);\n // Mark tasks as in progress\n await Promise.all(\n files.map((file) => markFileAsInProgress(file, filesStateFilePath))\n );\n\n // Construct prompt\n const dependencies = Object.fromEntries(\n files.map((file) => [\n file,\n Array.from(new Set(dag.getDependencies(file))).map(String),\n ])\n );\n const dependents = Object.fromEntries(\n files.map((file) => [\n file,\n Array.from(new Set(dag.getDependents(file))).map(String),\n ])\n );\n\n return getPrompt({\n targetFile: files,\n dependencyFiles: dependencies,\n dependentFiles: dependents,\n });\n },\n postProcess: async (processedFiles, context, agentReport) => {\n const { filesStateFilePath } = context;\n\n // Mark tasks as complete\n await Promise.all(\n processedFiles.map((file) => markFileAsEdited(file, filesStateFilePath))\n );\n\n // Add agent report\n reports.push(agentReport);\n\n // Update stats\n manager.stats.updateStats({\n newProcessedFiles: processedFiles.length,\n });\n\n // Update progress bar\n logger.progressBar.advance(\n processedFiles.length,\n `Processed ${Number((manager.stats.getStats().processedFiles / files.length) * 100).toFixed(2)}% of files`\n );\n },\n };\n\n // Run parallel processing\n await runParallelProcessing(\n Array.from(taskQueue),\n i18nProcessor,\n { dag, files, filesStateFilePath },\n {\n concurrency,\n batchSize,\n },\n 3\n );\n\n if (manager.isAborted()) {\n cleanupOnExit();\n await exit(1);\n return;\n }\n\n logger.progressBar.stop(\n `Processed ${files.length} files [${Math.round(\n (Date.now() - fileProcessingStartTime) / 1000\n )}s]`\n );\n\n const cleanupReports = await fixErrorsTask();\n if (cleanupReports) {\n reports.push(...cleanupReports);\n }\n\n // Generate report\n const reportSummary = `# Summary of locadex i18n changes\n${reports.join('\\n')}`;\n const summaryFilePath = path.join(\n manager.getLogDirectory(),\n 'locadex-report.md'\n );\n appendFileSync(summaryFilePath, reportSummary);\n logger.step(`Saved summary of changes to: ${summaryFilePath}`);\n\n // cleanup\n const formatter = await detectFormatter();\n if (formatter) {\n await formatFiles(files, formatter);\n }\n\n const lockfilePath = manager.getLockFilePath();\n\n // Update lockfile with processed files\n updateLockfile(files, lockfilePath, manager.rootDirectory);\n\n // Clean up stale entries from lockfile\n cleanupLockfile(lockfilePath, manager.rootDirectory);\n\n logger.message(chalk.dim(`Updated lockfile with ${files.length} files`));\n\n // Delete any files the AI may have arbitrarily created\n deleteAddedFiles(\n [path.relative(manager.rootDirectory, manager.locadexDirectory)],\n ['dictionary.json', 'gt.config.json', 'locadex.yml']\n );\n\n cleanupOnExit();\n\n // Run translate cmd\n if (isGTAuthConfigured()) {\n try {\n await execFunction('locadex', ['translate'], false, manager.appDirectory);\n logger.step(`Translations generated!`);\n } catch (error) {}\n } else {\n logger.step(\n `No GT_API_KEY or GT_PROJECT_ID found. Skipping translation...`\n );\n }\n\n outro(chalk.green('✅ Locadex i18n complete!'));\n await exit(0);\n}\n\nfunction cleanupOnExit() {\n const manager = LocadexManager.getInstance();\n logger.info(\n chalk.dim(\n `Total Cost: $${manager.stats.getStats().totalCost.toFixed(2)}\nTotal wall time: ${Math.round(\n (Date.now() - manager.stats.getStats().startTime) / 1000\n )}s\nTotal files processed: ${manager.stats.getStats().processedFiles}`\n )\n );\n\n const finalStats = manager.stats.getStats();\n\n // Record telemetry for final stats\n manager.stats.recordTelemetry(true);\n\n logger.verboseMessage(\n `Total input tokens: ${finalStats.inputTokens}\nTotal cached input tokens: ${finalStats.cachedInputTokens}\nTotal output tokens: ${finalStats.outputTokens}\nTotal turns: ${finalStats.turns}`\n );\n}\n\nfunction getPrompt({\n targetFile,\n dependencyFiles,\n dependentFiles,\n}: {\n targetFile: string[];\n dependencyFiles: Record<string, string[]>;\n dependentFiles: Record<string, string[]>;\n}) {\n const prompt = `# Task: Internationalize the target file(s) using gt-next.\n\n## INSTRUCTIONS\n\n- You are given a list of target files and their corresponding dependency/dependent files.\n- The project is already setup for internationalization. Do not try to setup the project again for i18n.\n\n## Workflow:\n1. **Gather context** Read the target files closely (you should not have to read the dependency/dependent files).\n2. **Evaluate if i18n is necessary** Evaluate if the target files need to be internationalized using gt-next \n - If the target files have no relevant content, are already internationalized, or contain build-time code (e.g. nextjs plugins) they should never be internationalized.\n**IMPORTANT**: IF NONE OF THE TARGET FILES NEED TO BE INTERNATIONALIZED, YOUR TASK IS COMPLETE AND YOU MAY RETURN.\n3. **Identify the tools to use** Given the contents of the files, ask yourself which tools and guides you need to use to get the necessary knowledge to internationalize the target files. Here are some helpful questions to evaluate for tool selection:\n - 3.a. Is the content that needs to be i18ned being used in this same file, or is it being used in another file?\n - 3.b. Is there any string interpolation that needs to be i18ned?\n - 3.c. Is there any conditional logic or rendering that needs to be i18ned?\n - 3.d. Is the content that needs to be i18ned HTML/JSX or a string?\n4. **Internationalize** You now have the necessary knowledge. Internationalize the files using the information from the tools provided to you.\n - 4.a. Do not run validation checks such as tsc. We will do that later.\n\n## RULES:\n- ALWAYS use the <T> component to internationalize HTML/JSX content.\n- ALWAYS use useGT() or useTranslations() to internationalize string content (strings created with '', \"\", or \\`\\`).\n - When possible, avoid using useTranslations(); useGT() is always preferred.\n- DO NOT internationalize non-user facing content or content that is functional, such as ids, class names, error strings, logical strings, etc.\n- Do not add i18n middleware to the app.\n- ALWAYS adhere to the guides provided via the 'mcp__locadex__' tools.\n - These guides provide additional knowledge about how to internationalize the content.\n- Minimize the footprint of your changes.\n- Focus on internationalizing all user facing content in the target files. \n- NEVER move content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR DELETE ANY FILES (especially .bak files)\n- NEVER EDIT FILES THAT ARE NOT GIVEN TO YOU.\n\n## TARGET FILE INFORMATION\n${targetFile.map(\n (file, index) => `\nTARGET FILE ${index + 1}:\n${file}\n\nDEPENDENCY FILES (files imported by target file ${index + 1}):\n${dependencyFiles[file].length > 0 ? ` ${dependencyFiles[file].join(', ')}` : 'none'}\n\nDEPENDENT FILES (files that import target file ${index + 1}):\n${dependentFiles[file].length > 0 ? ` ${dependentFiles[file].join(', ')}` : 'none'}\n`\n)}\n\n---\n\n## MCP TOOLS\n\n${allMcpPrompt}\n\n## Final output\n- When you are done, please return a brief summary of the files you modified, following this format.\n- **DO NOT** include any other text in your response. \n- If there were issues with some files, please include the issues in the list of changes for that file.\n\n[file 1 path]\n- List of changes to file 1\n`;\n\n return prompt;\n}\n"]}
1
+ {"version":3,"file":"i18n.js","sourceRoot":"/","sources":["tasks/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;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,CAAC,CAAC,MAAM;CACjF,CACA;;;;;;EAMC,YAAY;;;;;;;;;CASb,CAAC;IAEA,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createSpinner } from '../logging/console.js';\nimport { allMcpPrompt } from '../prompts/system.js';\nimport { exit } from '../utils/shutdown.js';\nimport { logger } from '../logging/logger.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport {\n addFilesToManager,\n markFileAsEdited,\n markFileAsInProgress,\n} from '../utils/dag/getFiles.js';\nimport { runParallelProcessing, TaskProcessor } from './concurrency.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { appendFileSync } from 'node:fs';\nimport { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';\nimport path from 'node:path';\nimport { updateLockfile, cleanupLockfile } from '../utils/lockfile.js';\nimport { extractFiles } from '../utils/dag/extractFiles.js';\nimport { Dag } from '../utils/dag/createDag.js';\nimport { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';\nimport { deleteAddedFiles } from '../utils/fs/git.js';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { installGlobalPackage } from '../utils/packages/installPackage.js';\nimport { fixErrorsTask } from './fixErrors.js';\nimport { getLocadexVersion } from '../utils/getPaths.js';\nimport { execFunction } from '../utils/exec.js';\nimport { isGTAuthConfigured } from '../utils/config.js';\nimport { CliOptions } from '../types/cli.js';\n\n/**\n * Run Locadex i18n on the project\n * This task requires no human intervention and is safe to run in CI/CD pipelines.\n */\nexport async function i18nTask(cliOptions: CliOptions) {\n const manager = LocadexManager.getInstance();\n // have to use the package.json from the appDir\n const packageJson = await getPackageJson(manager.appDirectory);\n const isUsingGTNext = packageJson\n ? isPackageInstalled('gt-next', packageJson)\n : false;\n if (!isUsingGTNext) {\n logger.error(\n `gt-next not detected in ${manager.appDirectory}. Please specify the correct app directory with the --app-dir flag, or ensure that gt-next is correctly installed in the project.`\n );\n await exit(1);\n }\n\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n // Install locadex if not installed\n await installGlobalPackage('locadex', getLocadexVersion());\n\n logger.debugMessage('App directory: ' + manager.appDirectory);\n logger.debugMessage('Root directory: ' + manager.rootDirectory);\n\n // Init message\n const spinner = createSpinner();\n spinner.start('Initializing Locadex...');\n\n const { files, dag } = extractFiles(manager);\n\n if (files.length === 0) {\n spinner.stop('No files have changed since last run');\n outro(chalk.green('✅ Locadex i18n complete - no changes detected!'));\n await exit(0);\n }\n\n const filesStateFilePath = manager.getFilesStateFilePath();\n const concurrency = manager.getMaxConcurrency();\n const batchSize = manager.getBatchSize();\n\n // Create the list of files (aka tasks) to process\n const taskQueue = Array.from(files);\n\n // Add files to manager\n const stateFilePath = addFilesToManager(filesStateFilePath, taskQueue);\n spinner.stop('Locadex initialized');\n\n logger.verboseMessage(`Processing ${files.length} modified files`);\n logger.debugMessage(`Track progress here: ${stateFilePath}`);\n logger.debugMessage(`Order:\\n${taskQueue.join('\\n')}`);\n\n logger.message(`Using ${concurrency} concurrent agents`);\n logger.initializeProgressBar(taskQueue.length);\n\n const fileProcessingStartTime = Date.now();\n logger.progressBar.start(`Processing ${taskQueue.length} files...`);\n\n // Shared reports array for collecting results\n const reports: string[] = [];\n\n // Create i18n task processor\n const i18nProcessor: TaskProcessor<\n string,\n {\n dag: Dag;\n files: string[];\n filesStateFilePath: string;\n }\n > = {\n preProcess: async (files, context) => {\n const { dag, filesStateFilePath } = context;\n logger.debugMessage(`Files: ${files.join(', ')}`);\n // Mark tasks as in progress\n await Promise.all(\n files.map((file) => markFileAsInProgress(file, filesStateFilePath))\n );\n\n // Construct prompt\n const dependencies = Object.fromEntries(\n files.map((file) => [\n file,\n Array.from(new Set(dag.getDependencies(file))).map(String),\n ])\n );\n const dependents = Object.fromEntries(\n files.map((file) => [\n file,\n Array.from(new Set(dag.getDependents(file))).map(String),\n ])\n );\n\n return getPrompt({\n targetFile: files,\n dependencyFiles: dependencies,\n dependentFiles: dependents,\n });\n },\n postProcess: async (processedFiles, context, agentReport) => {\n const { filesStateFilePath } = context;\n\n // Mark tasks as complete\n await Promise.all(\n processedFiles.map((file) => markFileAsEdited(file, filesStateFilePath))\n );\n\n // Add agent report\n reports.push(agentReport);\n\n // Update stats\n manager.stats.updateStats({\n newProcessedFiles: processedFiles.length,\n });\n\n // Update progress bar\n logger.progressBar.advance(\n processedFiles.length,\n `Processed ${Number((manager.stats.getStats().processedFiles / files.length) * 100).toFixed(2)}% of files`\n );\n },\n };\n\n // Run parallel processing\n await runParallelProcessing(\n Array.from(taskQueue),\n i18nProcessor,\n { dag, files, filesStateFilePath },\n {\n concurrency,\n batchSize,\n },\n 3\n );\n\n if (manager.isAborted()) {\n cleanupOnExit();\n await exit(1);\n return;\n }\n\n logger.progressBar.stop(\n `Processed ${files.length} files [${Math.round(\n (Date.now() - fileProcessingStartTime) / 1000\n )}s]`\n );\n\n const cleanupReports = await fixErrorsTask();\n if (cleanupReports) {\n reports.push(...cleanupReports);\n }\n\n // Generate report\n const reportSummary = `# Summary of locadex i18n changes\n${reports.join('\\n')}`;\n const summaryFilePath = path.join(\n manager.getLogDirectory(),\n 'locadex-report.md'\n );\n appendFileSync(summaryFilePath, reportSummary);\n logger.step(`Saved summary of changes to: ${summaryFilePath}`);\n\n // cleanup\n const formatter = await detectFormatter();\n if (formatter) {\n await formatFiles(files, formatter);\n }\n\n const lockfilePath = manager.getLockFilePath();\n\n // Update lockfile with processed files\n updateLockfile(files, lockfilePath, manager.rootDirectory);\n\n // Clean up stale entries from lockfile\n cleanupLockfile(lockfilePath, manager.rootDirectory);\n\n logger.message(chalk.dim(`Updated lockfile with ${files.length} files`));\n\n // Delete any files the AI may have arbitrarily created\n deleteAddedFiles(\n [path.relative(manager.rootDirectory, manager.locadexDirectory)],\n ['dictionary.json', 'gt.config.json', 'locadex.yml']\n );\n\n cleanupOnExit();\n\n // Run translate cmd\n if (isGTAuthConfigured(manager.appDirectory) && !cliOptions.noTranslate) {\n try {\n logger.initializeSpinner();\n logger.spinner.start('Running locadex translate...');\n await execFunction(\n 'locadex',\n ['translate'],\n false,\n manager.appDirectory,\n manager.getAgentAbortController()\n );\n logger.spinner.stop('Translations generated!');\n } catch (error) {\n logger.spinner.stop('Translations failed!');\n logger.error(\n `Error running 'locadex translate': ${(error as Error).message}`\n );\n }\n } else {\n logger.step(\n `No GT_API_KEY or GT_PROJECT_ID found. Skipping translation step...`\n );\n }\n\n outro(chalk.green('✅ Locadex i18n complete!'));\n await exit(0);\n}\n\nfunction cleanupOnExit() {\n const manager = LocadexManager.getInstance();\n logger.info(\n chalk.dim(\n `Locadex Cost: $${manager.stats.getStats().totalCost.toFixed(2)}\nLocadex wall time: ${Math.round(\n (Date.now() - manager.stats.getStats().startTime) / 1000\n )}s\nLocadex files processed: ${manager.stats.getStats().processedFiles}`\n )\n );\n\n const finalStats = manager.stats.getStats();\n\n // Record telemetry for final stats\n manager.stats.recordTelemetry(true);\n\n logger.verboseMessage(\n `Locadex input tokens: ${finalStats.inputTokens}\nLocadex cached input tokens: ${finalStats.cachedInputTokens}\nLocadex output tokens: ${finalStats.outputTokens}\nLocadex turns: ${finalStats.turns}`\n );\n}\n\nfunction getPrompt({\n targetFile,\n dependencyFiles,\n dependentFiles,\n}: {\n targetFile: string[];\n dependencyFiles: Record<string, string[]>;\n dependentFiles: Record<string, string[]>;\n}) {\n const prompt = `# Task: Internationalize the target file(s) using gt-next.\n\n## INSTRUCTIONS\n\n- You are given a list of target files and their corresponding dependency/dependent files.\n- The project is already setup for internationalization. Do not try to setup the project again for i18n.\n\n## Workflow:\n1. **Gather context** Read the target files closely (you should not have to read the dependency/dependent files).\n2. **Evaluate if i18n is necessary** Evaluate if the target files need to be internationalized using gt-next \n - If the target files have no relevant content, are already internationalized, or contain build-time code (e.g. nextjs plugins) they should never be internationalized.\n**IMPORTANT**: IF NONE OF THE TARGET FILES NEED TO BE INTERNATIONALIZED, YOUR TASK IS COMPLETE AND YOU MAY RETURN.\n3. **Identify the tools to use** Given the contents of the files, ask yourself which tools and guides you need to use to get the necessary knowledge to internationalize the target files. Here are some helpful questions to evaluate for tool selection:\n - 3.a. Is the content that needs to be i18ned being used in this same file, or is it being used in another file?\n - 3.b. Is there any string interpolation that needs to be i18ned?\n - 3.c. Is there any conditional logic or rendering that needs to be i18ned?\n - 3.d. Is the content that needs to be i18ned HTML/JSX or a string?\n4. **Internationalize** You now have the necessary knowledge. Internationalize the files using the information from the tools provided to you.\n - 4.a. Do not run validation checks such as tsc. We will do that later.\n\n## RULES:\n- ALWAYS use the <T> component to internationalize HTML/JSX content.\n- ALWAYS use useGT() or useTranslations() to internationalize string content (strings created with '', \"\", or \\`\\`).\n - When possible, avoid using useTranslations(); useGT() is always preferred.\n- DO NOT internationalize non-user facing content or content that is functional, such as ids, class names, error strings, logical strings, etc.\n- Do not add i18n middleware to the app.\n- ALWAYS adhere to the guides provided via the 'mcp__locadex__' tools.\n - These guides provide additional knowledge about how to internationalize the content.\n- Minimize the footprint of your changes.\n- Focus on internationalizing all user facing content in the target files. \n- NEVER move content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR DELETE ANY FILES (especially .bak files)\n- NEVER EDIT FILES THAT ARE NOT GIVEN TO YOU.\n\n## TARGET FILE INFORMATION\n${targetFile.map(\n (file, index) => `\nTARGET FILE ${index + 1}:\n${file}\n\nDEPENDENCY FILES (files imported by target file ${index + 1}):\n${dependencyFiles[file].length > 0 ? ` ${dependencyFiles[file].join(', ')}` : 'none'}\n\nDEPENDENT FILES (files that import target file ${index + 1}):\n${dependentFiles[file].length > 0 ? ` ${dependentFiles[file].join(', ')}` : 'none'}\n`\n)}\n\n---\n\n## MCP TOOLS\n\n${allMcpPrompt}\n\n## Final output\n- When you are done, please return a brief summary of the files you modified, following this format.\n- **DO NOT** include any other text in your response. \n- If there were issues with some files, please include the issues in the list of changes for that file.\n\n[file 1 path]\n- List of changes to file 1\n`;\n\n return prompt;\n}\n"]}
@@ -1,2 +1,8 @@
1
- export declare function setupTask(bypassPrompts: boolean, specifiedPackageManager?: string): Promise<void>;
1
+ import { CliOptions } from '../types/cli.js';
2
+ /**
3
+ * Run Locadex setup on the project
4
+ * If autoSetup is true, the task will run without human intervention.
5
+ * If autoSetup is false, the task may prompt the user for confirmation.
6
+ */
7
+ export declare function setupTask(cliOptions: CliOptions, autoSetup: boolean, bypassPrompts: boolean, specifiedPackageManager?: string): Promise<void>;
2
8
  //# sourceMappingURL=setup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["tasks/setup.ts"],"names":[],"mappings":"AA0BA,wBAAsB,SAAS,CAC7B,aAAa,EAAE,OAAO,EACtB,uBAAuB,CAAC,EAAE,MAAM,iBA4HjC"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["tasks/setup.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,OAAO,EACtB,uBAAuB,CAAC,EAAE,MAAM,iBAyIjC"}
@@ -1,6 +1,6 @@
1
1
  import { createSpinner, promptConfirm } from '../logging/console.js';
2
2
  import { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';
3
- import { getPackageManager } from 'gtx-cli/utils/packageManager';
3
+ import { getPackageManager, } from 'gtx-cli/utils/packageManager';
4
4
  import { installPackage } from 'gtx-cli/utils/installPackage';
5
5
  import chalk from 'chalk';
6
6
  import { logger } from '../logging/logger.js';
@@ -20,8 +20,17 @@ import { addTranslateScript, installGlobalPackage, } from '../utils/packages/ins
20
20
  import { CLAUDE_CODE_VERSION } from '../utils/shared.js';
21
21
  import { getLocadexVersion } from '../utils/getPaths.js';
22
22
  import { getResource } from '../resources/getResource.js';
23
- export async function setupTask(bypassPrompts, specifiedPackageManager) {
24
- if (!bypassPrompts) {
23
+ import { generateSettings } from 'gtx-cli/config/generateSettings';
24
+ import { setCredentials } from 'gtx-cli/utils/credentials';
25
+ import { retrieveCredentials } from 'gtx-cli/utils/credentials';
26
+ import { isGTAuthConfigured } from '../utils/config.js';
27
+ /**
28
+ * Run Locadex setup on the project
29
+ * If autoSetup is true, the task will run without human intervention.
30
+ * If autoSetup is false, the task may prompt the user for confirmation.
31
+ */
32
+ export async function setupTask(cliOptions, autoSetup, bypassPrompts, specifiedPackageManager) {
33
+ if (!bypassPrompts && !autoSetup) {
25
34
  await promptConfirm({
26
35
  message: chalk.yellow(`Locadex will modify files! Make sure you have committed or stashed any changes. Do you want to continue?`),
27
36
  defaultValue: true,
@@ -29,7 +38,17 @@ export async function setupTask(bypassPrompts, specifiedPackageManager) {
29
38
  });
30
39
  }
31
40
  const manager = LocadexManager.getInstance();
32
- const packageManager = await getPackageManager(manager.rootDirectory, specifiedPackageManager);
41
+ // Setup API keys
42
+ if (!autoSetup && !isGTAuthConfigured(manager.appDirectory)) {
43
+ const shouldGenerateApiKeys = await promptConfirm({
44
+ message: `Would you like locadex to automatically generate a General Translation API key and project ID for you?`,
45
+ defaultValue: true,
46
+ });
47
+ if (shouldGenerateApiKeys) {
48
+ await setupApiKeys('production', manager);
49
+ }
50
+ }
51
+ const packageManager = await getPackageManager(manager.rootDirectory, specifiedPackageManager, autoSetup);
33
52
  let appPackageJson = await getPackageJson(manager.appDirectory);
34
53
  if (appPackageJson) {
35
54
  if (!isPackageInstalled('gt-next', appPackageJson)) {
@@ -88,15 +107,16 @@ export async function setupTask(bypassPrompts, specifiedPackageManager) {
88
107
  // Set up locale selector
89
108
  await setupLocaleSelector();
90
109
  // Create dictionary.json file if not exists
91
- setupDictionary(manager);
110
+ // commented out because this trips up the AI
111
+ // setupDictionary(manager);
92
112
  // Add locadex github action if not exists
93
- setupGithubAction(manager);
113
+ setupGithubAction(manager, packageManager);
94
114
  const formatter = await detectFormatter();
95
115
  if (formatter && filesUpdated.length > 0) {
96
116
  await formatFiles(filesUpdated, formatter);
97
117
  }
98
118
  // Run i18n command
99
- await i18nTask();
119
+ await i18nTask(cliOptions);
100
120
  }
101
121
  function setupDictionary(manager) {
102
122
  const usingSrcDirectory = existsSync(path.join(manager.appDirectory, 'src'));
@@ -111,7 +131,7 @@ function setupDictionary(manager) {
111
131
  logger.step(`Found ${chalk.cyan('dictionary.json')} file at ${chalk.cyan(dictionaryPath)}. Skipping creation...`);
112
132
  }
113
133
  }
114
- function setupGithubAction(manager) {
134
+ function setupGithubAction(manager, packageManager) {
115
135
  const githubActionPath = path.join(manager.rootDirectory, '.github', 'workflows', 'locadex.yml');
116
136
  if (!existsSync(githubActionPath)) {
117
137
  mkdirSync(path.join(manager.rootDirectory, '.github', 'workflows'), {
@@ -119,8 +139,9 @@ function setupGithubAction(manager) {
119
139
  });
120
140
  const resource = getResource('ghaYaml.yml');
121
141
  if (resource.content) {
122
- writeFileSync(githubActionPath, resource.content);
123
- logger.step(`Created ${chalk.cyan('locadex.yml')} Github Action at ${chalk.cyan(githubActionPath)}.`);
142
+ const content = resource.content.replace('[packageManager install command]', packageManager.installAllCommand);
143
+ writeFileSync(githubActionPath, content);
144
+ logger.step(`Created ${chalk.cyan('locadex.yml')} Github Action at ${chalk.cyan(githubActionPath)}. You can edit this file to customize the Github Action. Make sure to add the corresponding secrets to your repo settings!`);
124
145
  }
125
146
  else {
126
147
  logger.error(`Error reading resource ghaYaml.yml: ${resource.error}`);
@@ -130,6 +151,11 @@ function setupGithubAction(manager) {
130
151
  logger.step(`Found ${chalk.cyan('locadex.yml')} Github Action at ${chalk.cyan(githubActionPath)}. Skipping creation...`);
131
152
  }
132
153
  }
154
+ async function setupApiKeys(keyType, manager) {
155
+ const settings = await generateSettings({}, manager.appDirectory);
156
+ const credentials = await retrieveCredentials(settings, keyType);
157
+ await setCredentials(credentials, keyType, settings.framework, manager.appDirectory);
158
+ }
133
159
  async function setupLocaleSelector() {
134
160
  logger.initializeSpinner();
135
161
  logger.spinner.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CAAC,YAAoB;IACnD,MAAM,MAAM,GAAG;;;;sBAIK,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BjC,CAAC;IACA,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createSpinner, promptConfirm } from '../logging/console.js';\nimport { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';\nimport { getPackageManager } from 'gtx-cli/utils/packageManager';\nimport { installPackage } from 'gtx-cli/utils/installPackage';\nimport chalk from 'chalk';\nimport { logger } from '../logging/logger.js';\nimport { findFilepaths } from '../utils/fs/findConfigs.js';\nimport { wrapContentNext } from 'gtx-cli/next/parse/wrapContent';\nimport { handleInitGT } from 'gtx-cli/next/parse/handleInitGT';\nimport { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';\nimport { createOrUpdateConfig } from 'gtx-cli/fs/config/setupConfig';\nimport { i18nTask } from '../tasks/i18n.js';\nimport { getNextDirectories } from '../utils/fs/getFiles.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { outro } from '@clack/prompts';\nimport { appendFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { exit } from '../utils/shutdown.js';\nimport {\n addTranslateScript,\n installGlobalPackage,\n} from '../utils/packages/installPackage.js';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { getLocadexVersion } from '../utils/getPaths.js';\nimport { getResource } from '../resources/getResource.js';\n\nexport async function setupTask(\n bypassPrompts: boolean,\n specifiedPackageManager?: string\n) {\n if (!bypassPrompts) {\n await promptConfirm({\n message: chalk.yellow(\n `Locadex will modify files! Make sure you have committed or stashed any changes. Do you want to continue?`\n ),\n defaultValue: true,\n cancelMessage: 'Operation cancelled.',\n });\n }\n\n const manager = LocadexManager.getInstance();\n\n const packageManager = await getPackageManager(\n manager.rootDirectory,\n specifiedPackageManager\n );\n let appPackageJson = await getPackageJson(manager.appDirectory);\n\n if (appPackageJson) {\n if (!isPackageInstalled('gt-next', appPackageJson)) {\n const spinner = createSpinner('timer');\n spinner.start(`Installing gt-next with ${packageManager.name}...`);\n await installPackage(\n 'gt-next',\n packageManager,\n false,\n manager.appDirectory\n );\n spinner.stop('Automatically installed gt-next.');\n }\n }\n\n const nextConfigPath = findFilepaths(\n [\n './next.config.js',\n './next.config.ts',\n './next.config.mjs',\n './next.config.mts',\n ],\n manager.appDirectory\n )[0];\n\n if (!nextConfigPath) {\n logger.error('No next.config.[js|ts|mjs|mts] file found.');\n await exit(1);\n }\n\n const errors: string[] = [];\n const warnings: string[] = [];\n let filesUpdated: string[] = [];\n\n const babel = createSpinner();\n\n babel.start('Wrapping <GTProvider> tags...');\n\n // Wrap all JSX elements in the src directory with a <T> tag, with unique ids\n const { filesUpdated: filesUpdatedNext } = await wrapContentNext(\n {\n src: getNextDirectories(manager.appDirectory),\n config: nextConfigPath,\n disableIds: true,\n disableFormatting: true,\n skipTs: true,\n addGTProvider: true,\n },\n 'gt-next',\n errors,\n warnings\n );\n filesUpdated = [...filesUpdated, ...filesUpdatedNext];\n\n babel.stop(`Modified ${filesUpdated.length} files.`);\n\n // Add the withGTConfig() function to the next.config.js file\n await handleInitGT(nextConfigPath, errors, warnings, filesUpdated);\n logger.step(`Added withGTConfig() to your ${nextConfigPath} file.`);\n\n // Create gt.config.json\n await createOrUpdateConfig(\n path.resolve(manager.appDirectory, 'gt.config.json'),\n {\n defaultLocale: 'en',\n locales: ['es', 'fr', 'de', 'ja', 'zh'],\n framework: 'next-app',\n }\n );\n\n logger.success(\n `Feel free to edit ${chalk.cyan(\n 'gt.config.json'\n )} to customize your translation setup. Docs: https://generaltranslation.com/docs/cli/reference/config`\n );\n\n // Add translate to scripts\n // Re-get the package.json to make sure it's updated\n appPackageJson = await getPackageJson(manager.appDirectory);\n if (appPackageJson) {\n await addTranslateScript(manager, appPackageJson, packageManager);\n }\n\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n\n // Install locadex if not installed\n await installGlobalPackage('locadex', getLocadexVersion());\n\n // Set up locale selector\n await setupLocaleSelector();\n\n // Create dictionary.json file if not exists\n setupDictionary(manager);\n\n // Add locadex github action if not exists\n setupGithubAction(manager);\n\n const formatter = await detectFormatter();\n if (formatter && filesUpdated.length > 0) {\n await formatFiles(filesUpdated, formatter);\n }\n\n // Run i18n command\n await i18nTask();\n}\n\nfunction setupDictionary(manager: LocadexManager) {\n const usingSrcDirectory = existsSync(path.join(manager.appDirectory, 'src'));\n const dictionaryPath = usingSrcDirectory\n ? path.join(manager.appDirectory, 'src', 'dictionary.json')\n : path.join(manager.appDirectory, 'dictionary.json');\n if (!existsSync(dictionaryPath)) {\n writeFileSync(dictionaryPath, '{}');\n logger.step(\n `Created ${chalk.cyan(\n 'dictionary.json'\n )} file at ${chalk.cyan(dictionaryPath)}.`\n );\n } else {\n logger.step(\n `Found ${chalk.cyan('dictionary.json')} file at ${chalk.cyan(\n dictionaryPath\n )}. Skipping creation...`\n );\n }\n}\n\nfunction setupGithubAction(manager: LocadexManager) {\n const githubActionPath = path.join(\n manager.rootDirectory,\n '.github',\n 'workflows',\n 'locadex.yml'\n );\n if (!existsSync(githubActionPath)) {\n mkdirSync(path.join(manager.rootDirectory, '.github', 'workflows'), {\n recursive: true,\n });\n const resource = getResource('ghaYaml.yml');\n if (resource.content) {\n writeFileSync(githubActionPath, resource.content);\n logger.step(\n `Created ${chalk.cyan(\n 'locadex.yml'\n )} Github Action at ${chalk.cyan(githubActionPath)}.`\n );\n } else {\n logger.error(`Error reading resource ghaYaml.yml: ${resource.error}`);\n }\n } else {\n logger.step(\n `Found ${chalk.cyan('locadex.yml')} Github Action at ${chalk.cyan(\n githubActionPath\n )}. Skipping creation...`\n );\n }\n}\nasync function setupLocaleSelector() {\n logger.initializeSpinner();\n logger.spinner.start('Creating locale selector...');\n\n // Create agent\n const manager = LocadexManager.getInstance();\n\n const agent = manager.createSingleAgent('claude_setup_agent', {});\n\n // Fix prompt\n const localeSelectorPrompt = getLocaleSelectorPrompt(manager.appDirectory);\n try {\n await agent.run(\n localeSelectorPrompt,\n {\n maxTurns: 50,\n timeoutSec: 120,\n maxRetries: 1,\n },\n {}\n );\n\n // Generate report\n const report = agent.generateReport();\n const reportSummary = `# Summary of locadex setup changes\n${report}`;\n const summaryFilePath = path.join(\n manager.getLogDirectory(),\n 'locadex-report.md'\n );\n appendFileSync(summaryFilePath, reportSummary);\n } catch (error) {\n agent.aggregateStats();\n // Check if this is an abort\n if (manager.getAgentAbortController().signal.aborted) {\n return;\n }\n logger.debugMessage(`[setup] Adding locale selector failed: ${error}`);\n outro(chalk.red('❌ Locadex setup failed!'));\n await exit(1);\n }\n agent.aggregateStats();\n\n logger.spinner.stop('Locale selector setup complete');\n}\n\nfunction getLocaleSelectorPrompt(appDirectory: string) {\n const prompt = `# Task: Add a locale selector to the app\n\n## Instructions\n- The locale selector should be a dropdown that allows the user to select the locale.\n- The app root is: \"${appDirectory}\"\n\n## LOCALE SELECTOR USAGE\n(1) Import the locale selector component from 'gt-next'\n(2) Add the locale selector to the app\n\nFor example:\nimport { LocaleSelector } from 'gt-next';\n\nfunction MyComponent() {\n return (\n <div>\n <LocaleSelector />\n <p>Hello, world!</p>\n </div>\n );\n}\n\n## RULES\n- The locale selector should be added to a header or footer or some other very obvious place in the app.\n- Scan across files to find the best place to add the locale selector.\n- **DO NOT** create new files. You may only modify existing files.\n- You do not need to mark the component containing the LocaleSelector with 'use client'. The LocaleSelector component is already internally marked with 'use client'.\n\n## Final output\n- When you are done, please return a **brief summary** of the files you modified.\n- **DO NOT** include any other text in your response.\n`;\n return prompt;\n}\n"]}
1
+ {"version":3,"file":"setup.js","sourceRoot":"/","sources":["tasks/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EACL,iBAAiB,GAElB,MAA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EAAE,CAAC;SACd,EACD,EAAE,CACH,CAAC;QAEF,kBAAkB;QAClB,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG;EACxB,MAAM,EAAE,CAAC;QACP,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAC/B,OAAO,CAAC,eAAe,EAAE,EACzB,mBAAmB,CACpB,CAAC;QACF,cAAc,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,4BAA4B;QAC5B,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACrD,OAAO;QACT,CAAC;QACD,MAAM,CAAC,YAAY,CAAC,0CAA0C,KAAK,EAAE,CAAC,CAAC;QACvE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAC5C,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,KAAK,CAAC,cAAc,EAAE,CAAC;IAEvB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,uBAAuB,CAAC,YAAoB;IACnD,MAAM,MAAM,GAAG;;;;sBAIK,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BjC,CAAC;IACA,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createSpinner, promptConfirm } from '../logging/console.js';\nimport { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';\nimport {\n getPackageManager,\n PackageManager,\n} from 'gtx-cli/utils/packageManager';\nimport { installPackage } from 'gtx-cli/utils/installPackage';\nimport chalk from 'chalk';\nimport { logger } from '../logging/logger.js';\nimport { findFilepaths } from '../utils/fs/findConfigs.js';\nimport { wrapContentNext } from 'gtx-cli/next/parse/wrapContent';\nimport { handleInitGT } from 'gtx-cli/next/parse/handleInitGT';\nimport { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';\nimport { createOrUpdateConfig } from 'gtx-cli/fs/config/setupConfig';\nimport { i18nTask } from '../tasks/i18n.js';\nimport { getNextDirectories } from '../utils/fs/getFiles.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { outro } from '@clack/prompts';\nimport { appendFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { exit } from '../utils/shutdown.js';\nimport {\n addTranslateScript,\n installGlobalPackage,\n} from '../utils/packages/installPackage.js';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { getLocadexVersion } from '../utils/getPaths.js';\nimport { getResource } from '../resources/getResource.js';\nimport { generateSettings } from 'gtx-cli/config/generateSettings';\nimport { setCredentials } from 'gtx-cli/utils/credentials';\nimport { retrieveCredentials } from 'gtx-cli/utils/credentials';\nimport { isGTAuthConfigured } from '../utils/config.js';\nimport { CliOptions } from '../types/cli.js';\n\n/**\n * Run Locadex setup on the project\n * If autoSetup is true, the task will run without human intervention.\n * If autoSetup is false, the task may prompt the user for confirmation.\n */\nexport async function setupTask(\n cliOptions: CliOptions,\n autoSetup: boolean,\n bypassPrompts: boolean,\n specifiedPackageManager?: string\n) {\n if (!bypassPrompts && !autoSetup) {\n await promptConfirm({\n message: chalk.yellow(\n `Locadex will modify files! Make sure you have committed or stashed any changes. Do you want to continue?`\n ),\n defaultValue: true,\n cancelMessage: 'Operation cancelled.',\n });\n }\n\n const manager = LocadexManager.getInstance();\n\n // Setup API keys\n if (!autoSetup && !isGTAuthConfigured(manager.appDirectory)) {\n const shouldGenerateApiKeys = await promptConfirm({\n message: `Would you like locadex to automatically generate a General Translation API key and project ID for you?`,\n defaultValue: true,\n });\n if (shouldGenerateApiKeys) {\n await setupApiKeys('production', manager);\n }\n }\n\n const packageManager = await getPackageManager(\n manager.rootDirectory,\n specifiedPackageManager,\n autoSetup\n );\n let appPackageJson = await getPackageJson(manager.appDirectory);\n\n if (appPackageJson) {\n if (!isPackageInstalled('gt-next', appPackageJson)) {\n const spinner = createSpinner('timer');\n spinner.start(`Installing gt-next with ${packageManager.name}...`);\n await installPackage(\n 'gt-next',\n packageManager,\n false,\n manager.appDirectory\n );\n spinner.stop('Automatically installed gt-next.');\n }\n }\n\n const nextConfigPath = findFilepaths(\n [\n './next.config.js',\n './next.config.ts',\n './next.config.mjs',\n './next.config.mts',\n ],\n manager.appDirectory\n )[0];\n\n if (!nextConfigPath) {\n logger.error('No next.config.[js|ts|mjs|mts] file found.');\n await exit(1);\n }\n\n const errors: string[] = [];\n const warnings: string[] = [];\n let filesUpdated: string[] = [];\n\n const babel = createSpinner();\n\n babel.start('Wrapping <GTProvider> tags...');\n\n // Wrap all JSX elements in the src directory with a <T> tag, with unique ids\n const { filesUpdated: filesUpdatedNext } = await wrapContentNext(\n {\n src: getNextDirectories(manager.appDirectory),\n config: nextConfigPath,\n disableIds: true,\n disableFormatting: true,\n skipTs: true,\n addGTProvider: true,\n },\n 'gt-next',\n errors,\n warnings\n );\n filesUpdated = [...filesUpdated, ...filesUpdatedNext];\n\n babel.stop(`Modified ${filesUpdated.length} files.`);\n\n // Add the withGTConfig() function to the next.config.js file\n await handleInitGT(nextConfigPath, errors, warnings, filesUpdated);\n logger.step(`Added withGTConfig() to your ${nextConfigPath} file.`);\n\n // Create gt.config.json\n await createOrUpdateConfig(\n path.resolve(manager.appDirectory, 'gt.config.json'),\n {\n defaultLocale: 'en',\n locales: ['es', 'fr', 'de', 'ja', 'zh'],\n framework: 'next-app',\n }\n );\n\n logger.success(\n `Feel free to edit ${chalk.cyan(\n 'gt.config.json'\n )} to customize your translation setup. Docs: https://generaltranslation.com/docs/cli/reference/config`\n );\n\n // Add translate to scripts\n // Re-get the package.json to make sure it's updated\n appPackageJson = await getPackageJson(manager.appDirectory);\n if (appPackageJson) {\n await addTranslateScript(manager, appPackageJson, packageManager);\n }\n\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n\n // Install locadex if not installed\n await installGlobalPackage('locadex', getLocadexVersion());\n\n // Set up locale selector\n await setupLocaleSelector();\n\n // Create dictionary.json file if not exists\n // commented out because this trips up the AI\n // setupDictionary(manager);\n\n // Add locadex github action if not exists\n setupGithubAction(manager, packageManager);\n\n const formatter = await detectFormatter();\n if (formatter && filesUpdated.length > 0) {\n await formatFiles(filesUpdated, formatter);\n }\n\n // Run i18n command\n await i18nTask(cliOptions);\n}\n\nfunction setupDictionary(manager: LocadexManager) {\n const usingSrcDirectory = existsSync(path.join(manager.appDirectory, 'src'));\n const dictionaryPath = usingSrcDirectory\n ? path.join(manager.appDirectory, 'src', 'dictionary.json')\n : path.join(manager.appDirectory, 'dictionary.json');\n if (!existsSync(dictionaryPath)) {\n writeFileSync(dictionaryPath, '{}');\n logger.step(\n `Created ${chalk.cyan(\n 'dictionary.json'\n )} file at ${chalk.cyan(dictionaryPath)}.`\n );\n } else {\n logger.step(\n `Found ${chalk.cyan('dictionary.json')} file at ${chalk.cyan(\n dictionaryPath\n )}. Skipping creation...`\n );\n }\n}\n\nfunction setupGithubAction(\n manager: LocadexManager,\n packageManager: PackageManager\n) {\n const githubActionPath = path.join(\n manager.rootDirectory,\n '.github',\n 'workflows',\n 'locadex.yml'\n );\n if (!existsSync(githubActionPath)) {\n mkdirSync(path.join(manager.rootDirectory, '.github', 'workflows'), {\n recursive: true,\n });\n const resource = getResource('ghaYaml.yml');\n if (resource.content) {\n const content = resource.content.replace(\n '[packageManager install command]',\n packageManager.installAllCommand\n );\n writeFileSync(githubActionPath, content);\n logger.step(\n `Created ${chalk.cyan(\n 'locadex.yml'\n )} Github Action at ${chalk.cyan(githubActionPath)}. You can edit this file to customize the Github Action. Make sure to add the corresponding secrets to your repo settings!`\n );\n } else {\n logger.error(`Error reading resource ghaYaml.yml: ${resource.error}`);\n }\n } else {\n logger.step(\n `Found ${chalk.cyan('locadex.yml')} Github Action at ${chalk.cyan(\n githubActionPath\n )}. Skipping creation...`\n );\n }\n}\n\nasync function setupApiKeys(\n keyType: 'development' | 'production',\n manager: LocadexManager\n) {\n const settings = await generateSettings({}, manager.appDirectory);\n const credentials = await retrieveCredentials(settings, keyType);\n await setCredentials(\n credentials,\n keyType,\n settings.framework,\n manager.appDirectory\n );\n}\n\nasync function setupLocaleSelector() {\n logger.initializeSpinner();\n logger.spinner.start('Creating locale selector...');\n\n // Create agent\n const manager = LocadexManager.getInstance();\n\n const agent = manager.createSingleAgent('claude_setup_agent', {});\n\n // Fix prompt\n const localeSelectorPrompt = getLocaleSelectorPrompt(manager.appDirectory);\n try {\n await agent.run(\n localeSelectorPrompt,\n {\n maxTurns: 50,\n timeoutSec: 120,\n maxRetries: 1,\n },\n {}\n );\n\n // Generate report\n const report = agent.generateReport();\n const reportSummary = `# Summary of locadex setup changes\n${report}`;\n const summaryFilePath = path.join(\n manager.getLogDirectory(),\n 'locadex-report.md'\n );\n appendFileSync(summaryFilePath, reportSummary);\n } catch (error) {\n agent.aggregateStats();\n // Check if this is an abort\n if (manager.getAgentAbortController().signal.aborted) {\n return;\n }\n logger.debugMessage(`[setup] Adding locale selector failed: ${error}`);\n outro(chalk.red('❌ Locadex setup failed!'));\n await exit(1);\n }\n agent.aggregateStats();\n\n logger.spinner.stop('Locale selector setup complete');\n}\n\nfunction getLocaleSelectorPrompt(appDirectory: string) {\n const prompt = `# Task: Add a locale selector to the app\n\n## Instructions\n- The locale selector should be a dropdown that allows the user to select the locale.\n- The app root is: \"${appDirectory}\"\n\n## LOCALE SELECTOR USAGE\n(1) Import the locale selector component from 'gt-next'\n(2) Add the locale selector to the app\n\nFor example:\nimport { LocaleSelector } from 'gt-next';\n\nfunction MyComponent() {\n return (\n <div>\n <LocaleSelector />\n <p>Hello, world!</p>\n </div>\n );\n}\n\n## RULES\n- The locale selector should be added to a header or footer or some other very obvious place in the app.\n- Scan across files to find the best place to add the locale selector.\n- **DO NOT** create new files. You may only modify existing files.\n- You do not need to mark the component containing the LocaleSelector with 'use client'. The LocaleSelector component is already internally marked with 'use client'.\n\n## Final output\n- When you are done, please return a **brief summary** of the files you modified.\n- **DO NOT** include any other text in your response.\n`;\n return prompt;\n}\n"]}
@@ -7,6 +7,7 @@ export type CliOptions = {
7
7
  matchingFiles?: string;
8
8
  appDir: string;
9
9
  timeout?: string;
10
+ noTranslate?: boolean;
10
11
  };
11
12
  export type LocadexConfig = {
12
13
  batchSize: number;
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"/","sources":["types/cli.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"/","sources":["types/cli.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"/","sources":["types/cli.ts"],"names":[],"mappings":"","sourcesContent":["export type CliOptions = {\n verbose?: boolean;\n debug?: boolean;\n noTelemetry?: boolean;\n batchSize?: string;\n concurrency?: string;\n matchingFiles?: string;\n appDir: string;\n timeout?: string;\n};\n\nexport type LocadexConfig = {\n batchSize: number;\n maxConcurrency: number;\n matchingFiles: string[];\n timeout: number;\n};\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"/","sources":["types/cli.ts"],"names":[],"mappings":"","sourcesContent":["export type CliOptions = {\n verbose?: boolean;\n debug?: boolean;\n noTelemetry?: boolean;\n batchSize?: string;\n concurrency?: string;\n matchingFiles?: string;\n appDir: string;\n timeout?: string;\n noTranslate?: boolean;\n};\n\nexport type LocadexConfig = {\n batchSize: number;\n maxConcurrency: number;\n matchingFiles: string[];\n timeout: number;\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import { CliOptions, LocadexConfig } from '../types/cli.js';
2
2
  export declare function validateConfig(options: CliOptions): Promise<void>;
3
- export declare function isGTAuthConfigured(): string | undefined;
3
+ export declare function isGTAuthConfigured(cwd?: string): string | undefined;
4
4
  export declare function createConfig(directory: string, options: {
5
5
  batchSize: number;
6
6
  maxConcurrency: number;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"/","sources":["utils/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG5D,wBAAsB,cAAc,CAAC,OAAO,EAAE,UAAU,iBA8BvD;AAED,wBAAgB,kBAAkB,uBAEjC;AAID,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,QAeF;AAED,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GACnC,aAAa,CA4Bf"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"/","sources":["utils/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAI5D,wBAAsB,cAAc,CAAC,OAAO,EAAE,UAAU,iBA8BvD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,sBAO9C;AAID,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,QAeF;AAED,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GACnC,aAAa,CA4Bf"}
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { logger } from '../logging/logger.js';
3
3
  import path from 'node:path';
4
4
  import { exit } from './shutdown.js';
5
+ import dotenv from 'dotenv';
5
6
  export async function validateConfig(options) {
6
7
  // Validate ANTHROPIC_API_KEY
7
8
  if (!process.env.ANTHROPIC_API_KEY) {
@@ -30,7 +31,12 @@ export async function validateConfig(options) {
30
31
  }
31
32
  }
32
33
  }
33
- export function isGTAuthConfigured() {
34
+ export function isGTAuthConfigured(cwd) {
35
+ if (cwd) {
36
+ dotenv.config({ path: path.join(cwd, '.env.production') });
37
+ dotenv.config({ path: path.join(cwd, '.env.local') });
38
+ dotenv.config({ path: path.join(cwd, '.env') });
39
+ }
34
40
  return process.env.GT_API_KEY && process.env.GT_PROJECT_ID;
35
41
  }
36
42
  const CONFIG_FILE_NAME = 'locadex.config.json';
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"/","sources":["utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAmB;IACtD,6BAA6B;IAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QACnC,OAAO,CAAC,KAAK,CACX,wGAAwG,CACzG,CAAC;QACF,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;YAC1E,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5C,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C,MAAM,cAAc,GAAkB;QACpC,SAAS,EAAE,EAAE;QACb,cAAc,EAAE,CAAC;QACjB,aAAa,EAAE;YACb,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,GAAG,uBAAuB;SAChE;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAC9D,IAAI,UAAU,GAA2B,EAAE,CAAC;IAE5C,gCAAgC;IAChC,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CACV,6BAA6B,UAAU,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACrG,CAAC;YACF,iDAAiD;QACnD,CAAC;IACH,CAAC;IAED,gEAAgE;IAChE,MAAM,YAAY,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;IAEtE,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { logger } from '../logging/logger.js';\nimport path from 'node:path';\nimport { CliOptions, LocadexConfig } from '../types/cli.js';\nimport { exit } from './shutdown.js';\n\nexport async function validateConfig(options: CliOptions) {\n // Validate ANTHROPIC_API_KEY\n if (!process.env.ANTHROPIC_API_KEY) {\n console.error(\n 'ANTHROPIC_API_KEY is not set! Please set it as an environment variable or in a .env | .env.local file.'\n );\n await exit(1);\n }\n\n if (options.timeout) {\n const timeout = Number(options.timeout);\n if (isNaN(timeout) || timeout <= 0) {\n console.error('Invalid timeout value. Please provide a positive number.');\n await exit(1);\n }\n }\n if (options.batchSize) {\n const batchSize = Number(options.batchSize);\n if (isNaN(batchSize) || batchSize < 1) {\n console.error('Invalid batch size. Please provide a positive number.');\n await exit(1);\n }\n }\n if (options.concurrency) {\n const concurrency = Number(options.concurrency);\n if (isNaN(concurrency) || concurrency < 1) {\n console.error('Invalid concurrency. Please provide a positive number.');\n await exit(1);\n }\n }\n}\n\nexport function isGTAuthConfigured() {\n return process.env.GT_API_KEY && process.env.GT_PROJECT_ID;\n}\n\nconst CONFIG_FILE_NAME = 'locadex.config.json';\n\nexport function createConfig(\n directory: string,\n options: {\n batchSize: number;\n maxConcurrency: number;\n matchingFiles: string[];\n timeout: number;\n }\n) {\n const configPath = path.resolve(directory, CONFIG_FILE_NAME);\n if (existsSync(configPath)) {\n return;\n }\n\n const config = {\n batchSize: options.batchSize,\n maxConcurrency: options.maxConcurrency,\n matchingFiles: options.matchingFiles,\n timeout: options.timeout,\n };\n\n writeFileSync(configPath, JSON.stringify(config, null, 2));\n}\n\nexport function getConfig(\n locadexDir: string,\n rootDir: string,\n appDir: string,\n options: Partial<LocadexConfig> = {}\n): LocadexConfig {\n const DEFAULT_CONFIG: LocadexConfig = {\n batchSize: 10,\n maxConcurrency: 1,\n matchingFiles: [\n `${path.relative(rootDir, appDir) || '.'}/**/*.{ts,tsx,js,jsx}`,\n ],\n timeout: 60,\n };\n const configPath = path.resolve(locadexDir, CONFIG_FILE_NAME);\n let fileConfig: Partial<LocadexConfig> = {};\n\n // Load config file if it exists\n if (existsSync(configPath)) {\n try {\n fileConfig = JSON.parse(readFileSync(configPath, 'utf8'));\n } catch (error) {\n logger.error(\n `Error parsing config file ${configPath}: ${error instanceof Error ? error.message : String(error)}`\n );\n // Continue with empty file config on parse error\n }\n }\n\n // Merge configurations: defaults < file config < passed options\n const mergedConfig = { ...DEFAULT_CONFIG, ...fileConfig, ...options };\n\n return mergedConfig;\n}\n"]}
1
+ {"version":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,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,UAAkB,EAClB,OAAe,EACf,MAAc,EACd,UAAkC,EAAE;IAEpC,MAAM,cAAc,GAAkB;QACpC,SAAS,EAAE,EAAE;QACb,cAAc,EAAE,CAAC;QACjB,aAAa,EAAE;YACb,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,GAAG,uBAAuB;SAChE;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAC9D,IAAI,UAAU,GAA2B,EAAE,CAAC;IAE5C,gCAAgC;IAChC,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CACV,6BAA6B,UAAU,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACrG,CAAC;YACF,iDAAiD;QACnD,CAAC;IACH,CAAC;IAED,gEAAgE;IAChE,MAAM,YAAY,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;IAEtE,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { logger } from '../logging/logger.js';\nimport path from 'node:path';\nimport { CliOptions, LocadexConfig } from '../types/cli.js';\nimport { exit } from './shutdown.js';\nimport dotenv from 'dotenv';\n\nexport async function validateConfig(options: CliOptions) {\n // Validate ANTHROPIC_API_KEY\n if (!process.env.ANTHROPIC_API_KEY) {\n console.error(\n 'ANTHROPIC_API_KEY is not set! Please set it as an environment variable or in a .env | .env.local file.'\n );\n await exit(1);\n }\n\n if (options.timeout) {\n const timeout = Number(options.timeout);\n if (isNaN(timeout) || timeout <= 0) {\n console.error('Invalid timeout value. Please provide a positive number.');\n await exit(1);\n }\n }\n if (options.batchSize) {\n const batchSize = Number(options.batchSize);\n if (isNaN(batchSize) || batchSize < 1) {\n console.error('Invalid batch size. Please provide a positive number.');\n await exit(1);\n }\n }\n if (options.concurrency) {\n const concurrency = Number(options.concurrency);\n if (isNaN(concurrency) || concurrency < 1) {\n console.error('Invalid concurrency. Please provide a positive number.');\n await exit(1);\n }\n }\n}\n\nexport function isGTAuthConfigured(cwd?: string) {\n if (cwd) {\n dotenv.config({ path: path.join(cwd, '.env.production') });\n dotenv.config({ path: path.join(cwd, '.env.local') });\n dotenv.config({ path: path.join(cwd, '.env') });\n }\n return process.env.GT_API_KEY && process.env.GT_PROJECT_ID;\n}\n\nconst CONFIG_FILE_NAME = 'locadex.config.json';\n\nexport function createConfig(\n directory: string,\n options: {\n batchSize: number;\n maxConcurrency: number;\n matchingFiles: string[];\n timeout: number;\n }\n) {\n const configPath = path.resolve(directory, CONFIG_FILE_NAME);\n if (existsSync(configPath)) {\n return;\n }\n\n const config = {\n batchSize: options.batchSize,\n maxConcurrency: options.maxConcurrency,\n matchingFiles: options.matchingFiles,\n timeout: options.timeout,\n };\n\n writeFileSync(configPath, JSON.stringify(config, null, 2));\n}\n\nexport function getConfig(\n locadexDir: string,\n rootDir: string,\n appDir: string,\n options: Partial<LocadexConfig> = {}\n): LocadexConfig {\n const DEFAULT_CONFIG: LocadexConfig = {\n batchSize: 10,\n maxConcurrency: 1,\n matchingFiles: [\n `${path.relative(rootDir, appDir) || '.'}/**/*.{ts,tsx,js,jsx}`,\n ],\n timeout: 60,\n };\n const configPath = path.resolve(locadexDir, CONFIG_FILE_NAME);\n let fileConfig: Partial<LocadexConfig> = {};\n\n // Load config file if it exists\n if (existsSync(configPath)) {\n try {\n fileConfig = JSON.parse(readFileSync(configPath, 'utf8'));\n } catch (error) {\n logger.error(\n `Error parsing config file ${configPath}: ${error instanceof Error ? error.message : String(error)}`\n );\n // Continue with empty file config on parse error\n }\n }\n\n // Merge configurations: defaults < file config < passed options\n const mergedConfig = { ...DEFAULT_CONFIG, ...fileConfig, ...options };\n\n return mergedConfig;\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare function execFunction(command: string, args: string[], pipeStdout?: boolean, cwd?: string): Promise<void>;
1
+ export declare function execFunction(command: string, args: string[], pipeStdout?: boolean, cwd?: string, parentAbortController?: AbortController): Promise<void>;
2
2
  //# sourceMappingURL=exec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exec.d.ts","sourceRoot":"/","sources":["utils/exec.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,UAAU,GAAE,OAAc,EAC1B,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAyCf"}
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"/","sources":["utils/exec.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,UAAU,GAAE,OAAc,EAC1B,GAAG,GAAE,MAAsB,EAC3B,qBAAqB,CAAC,EAAE,eAAe,GACtC,OAAO,CAAC,IAAI,CAAC,CA+Df"}
@@ -1,21 +1,35 @@
1
1
  import chalk from 'chalk';
2
2
  import { spawn } from 'node:child_process';
3
3
  import { logger } from '../logging/logger.js';
4
- export async function execFunction(command, args, pipeStdout = true, cwd = process.cwd()) {
4
+ export async function execFunction(command, args, pipeStdout = true, cwd = process.cwd(), parentAbortController) {
5
5
  return new Promise((resolve, reject) => {
6
+ const abortController = new AbortController();
7
+ // Listen for parent abort signal
8
+ if (parentAbortController) {
9
+ parentAbortController.signal.addEventListener('abort', () => {
10
+ abortController.abort();
11
+ reject(new Error('Process aborted by parent'));
12
+ });
13
+ }
6
14
  const childProcess = spawn(command, args, {
7
15
  stdio: ['ignore', 'pipe', 'pipe'],
8
16
  cwd,
17
+ signal: abortController.signal,
9
18
  });
10
19
  let errorOutput = '';
20
+ const timeout = global.setTimeout(() => {
21
+ abortController.abort();
22
+ reject(new Error(`Process timed out after 5 minutes`));
23
+ }, 5 * 60 * 1000);
11
24
  if (childProcess.stderr) {
12
25
  childProcess.stderr.on('data', (data) => {
13
- errorOutput += data.toString();
26
+ errorOutput = data.toString();
14
27
  });
15
28
  }
16
29
  childProcess.stdout.on('data', (data) => {
30
+ errorOutput = data.toString();
17
31
  if (!pipeStdout) {
18
- logger.debugMessage(data.toString());
32
+ logger.log(data.toString());
19
33
  }
20
34
  else {
21
35
  // eslint-disable-next-line no-console
@@ -23,19 +37,21 @@ export async function execFunction(command, args, pipeStdout = true, cwd = proce
23
37
  }
24
38
  });
25
39
  childProcess.on('error', (error) => {
26
- logger.error(chalk.red(`${command} error: ${error.message}`));
40
+ global.clearTimeout(timeout);
27
41
  reject(error);
28
42
  });
29
43
  childProcess.on('close', (code) => {
44
+ global.clearTimeout(timeout);
30
45
  if (code === 0) {
31
46
  resolve();
32
47
  }
33
48
  else {
34
- logger.error(chalk.red(`${command} failed with exit code ${code}`));
49
+ logger.log(chalk.red(`${command} failed with exit code ${code}`));
35
50
  if (errorOutput) {
36
- logger.debugMessage(chalk.red(`Error details: ${errorOutput}`));
51
+ logger.log(chalk.red(`Error details: ${errorOutput}`));
37
52
  }
38
- reject(new Error(`Process exited with code ${code}`));
53
+ // reject with the most recent output
54
+ reject(new Error(errorOutput));
39
55
  }
40
56
  });
41
57
  });
@@ -1 +1 @@
1
- {"version":3,"file":"exec.js","sourceRoot":"/","sources":["utils/exec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3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E,CAAC,IAAI,EAAE,EAAE;YAChC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,0BAA0B,IAAI,EAAE,CAAC,CAAC,CAAC;gBACpE,IAAI,WAAW,EAAE,CAAC;oBAChB,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,WAAW,EAAE,CAAC,CAAC,CAAC;gBAClE,CAAC;gBACD,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { spawn } from 'node:child_process';\nimport { logger } from '../logging/logger.js';\n\nexport async function execFunction(\n command: string,\n args: string[],\n pipeStdout: boolean = true,\n cwd: string = process.cwd()\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const childProcess = spawn(command, args, {\n stdio: ['ignore', 'pipe', 'pipe'],\n cwd,\n });\n\n let errorOutput = '';\n\n if (childProcess.stderr) {\n childProcess.stderr.on('data', (data) => {\n errorOutput += data.toString();\n });\n }\n\n childProcess.stdout.on('data', (data) => {\n if (!pipeStdout) {\n logger.debugMessage(data.toString());\n } else {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n }\n });\n\n childProcess.on('error', (error) => {\n logger.error(chalk.red(`${command} error: ${error.message}`));\n reject(error);\n });\n\n childProcess.on('close', (code) => {\n if (code === 0) {\n resolve();\n } else {\n logger.error(chalk.red(`${command} failed with exit code ${code}`));\n if (errorOutput) {\n logger.debugMessage(chalk.red(`Error details: ${errorOutput}`));\n }\n reject(new Error(`Process exited with code ${code}`));\n }\n });\n });\n}\n"]}
1
+ {"version":3,"file":"exec.js","sourceRoot":"/","sources":["utils/exec.ts"],"names":[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chalk';\nimport { spawn } from 'node:child_process';\nimport { logger } from '../logging/logger.js';\n\nexport async function execFunction(\n command: string,\n args: string[],\n pipeStdout: boolean = true,\n cwd: string = process.cwd(),\n parentAbortController?: AbortController\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const abortController = new AbortController();\n\n // Listen for parent abort signal\n if (parentAbortController) {\n parentAbortController.signal.addEventListener('abort', () => {\n abortController.abort();\n reject(new Error('Process aborted by parent'));\n });\n }\n\n const childProcess = spawn(command, args, {\n stdio: ['ignore', 'pipe', 'pipe'],\n cwd,\n signal: abortController.signal,\n });\n\n let errorOutput = '';\n\n const timeout = global.setTimeout(\n () => {\n abortController.abort();\n reject(new Error(`Process timed out after 5 minutes`));\n },\n 5 * 60 * 1000\n );\n\n if (childProcess.stderr) {\n childProcess.stderr.on('data', (data) => {\n errorOutput = data.toString();\n });\n }\n\n childProcess.stdout.on('data', (data) => {\n errorOutput = data.toString();\n if (!pipeStdout) {\n logger.log(data.toString());\n } else {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n }\n });\n\n childProcess.on('error', (error) => {\n global.clearTimeout(timeout);\n reject(error);\n });\n\n childProcess.on('close', (code) => {\n global.clearTimeout(timeout);\n if (code === 0) {\n resolve();\n } else {\n logger.log(chalk.red(`${command} failed with exit code ${code}`));\n if (errorOutput) {\n logger.log(chalk.red(`Error details: ${errorOutput}`));\n }\n // reject with the most recent output\n reject(new Error(errorOutput));\n }\n });\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"lockfile.d.ts","sourceRoot":"/","sources":["utils/lockfile.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,UAAU,CAAC;AACxC,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,a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AgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,EAAE,MAAM,GACnB,MAAM,EAAE,CA2BV;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,IAAI,CAoCN;AAED,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,IAAI,CAqBN"}
@@ -66,18 +66,30 @@ export function getChangedFiles(files, lockfilePath) {
66
66
  }
67
67
  export function updateLockfile(files, lockfilePath, rootDirectory) {
68
68
  const lockfile = loadLockfile(lockfilePath);
69
+ // Build a map of paths to hashes for efficient lookup
70
+ const pathToHashMap = new Map();
71
+ for (const [hash, entry] of Object.entries(lockfile.checksums)) {
72
+ pathToHashMap.set(entry.path, hash);
73
+ }
69
74
  for (const filePath of files) {
70
75
  const relativePath = path.relative(rootDirectory, filePath);
71
76
  const currentHash = calculateFileHash(filePath);
72
77
  if (!currentHash) {
73
78
  continue;
74
79
  }
80
+ // Remove old hash entry for this file path (O(1) lookup and deletion)
81
+ const oldHash = pathToHashMap.get(relativePath);
82
+ if (oldHash) {
83
+ delete lockfile.checksums[oldHash];
84
+ }
75
85
  const stats = fs.statSync(filePath);
76
86
  // Use hash as key, store current path and metadata
77
87
  lockfile.checksums[currentHash] = {
78
88
  path: relativePath,
79
89
  lastModified: stats.mtime.getTime(),
80
90
  };
91
+ // Update the path-to-hash mapping
92
+ pathToHashMap.set(relativePath, currentHash);
81
93
  }
82
94
  saveLockfile(lockfilePath, lockfile);
83
95
  logger.debugMessage(`Updated lockfile with ${files.length} files`);
@@ -1 +1 @@
1
- {"version":3,"file":"lockfile.js","sourceRoot":"/","sources":["utils/lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;A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ACjB,cAAc,YAAY,8BAA8B,CACzD,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../logging/logger.js';\n\nexport const LOCKFILE_VERSION = '1.0.0';\nexport const LOCKFILE_NAME = 'locadex-lock.json';\n\nexport interface LockfileEntry {\n path: string;\n lastModified: number;\n}\n\nexport interface Lockfile {\n checksums: Record<string, LockfileEntry>; // checksum -> entry mapping\n version: string;\n updatedAt: string;\n}\n\nexport function calculateFileHash(filePath: string): string {\n try {\n const content = fs.readFileSync(filePath, 'utf8');\n return crypto.createHash('md5').update(content).digest('hex');\n } catch (error) {\n logger.debugMessage(`Failed to calculate hash for ${filePath}: ${error}`);\n return '';\n }\n}\n\nexport function loadLockfile(lockfilePath: string): Lockfile {\n try {\n if (!fs.existsSync(lockfilePath)) {\n return {\n checksums: {},\n version: '1.0.0',\n updatedAt: new Date().toISOString(),\n };\n }\n\n const content = fs.readFileSync(lockfilePath, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n logger.debugMessage(`Failed to load lockfile ${lockfilePath}: ${error}`);\n return {\n checksums: {},\n version: '1.0.0',\n updatedAt: new Date().toISOString(),\n };\n }\n}\n\nexport function saveLockfile(lockfilePath: string, lockfile: Lockfile): void {\n try {\n lockfile.updatedAt = new Date().toISOString();\n fs.writeFileSync(lockfilePath, JSON.stringify(lockfile, null, 2));\n } catch (error) {\n logger.debugMessage(`Failed to save lockfile ${lockfilePath}: ${error}`);\n }\n}\n\nexport function getChangedFiles(\n files: string[],\n lockfilePath: string\n): string[] {\n const lockfile = loadLockfile(lockfilePath);\n const changedFiles: string[] = [];\n\n for (const filePath of files) {\n const currentHash = calculateFileHash(filePath);\n\n if (!currentHash) {\n // Skip files that can't be hashed (likely don't exist or can't be read)\n continue;\n }\n\n // Check if this content hash exists in the lockfile\n const lockfileEntry = lockfile.checksums[currentHash];\n\n if (!lockfileEntry) {\n // Content hash not found, this is new or changed content\n changedFiles.push(filePath);\n }\n // If hash exists, content hasn't changed regardless of file path\n }\n\n logger.debugMessage(\n `Found ${changedFiles.length} changed files out of ${files.length} total files`\n );\n\n return changedFiles;\n}\n\nexport function updateLockfile(\n files: string[],\n lockfilePath: string,\n rootDirectory: string\n): void {\n const lockfile = loadLockfile(lockfilePath);\n\n for (const filePath of files) {\n const relativePath = path.relative(rootDirectory, filePath);\n const currentHash = calculateFileHash(filePath);\n\n if (!currentHash) {\n continue;\n }\n\n const stats = fs.statSync(filePath);\n // Use hash as key, store current path and metadata\n lockfile.checksums[currentHash] = {\n path: relativePath,\n lastModified: stats.mtime.getTime(),\n };\n }\n\n saveLockfile(lockfilePath, lockfile);\n logger.debugMessage(`Updated lockfile with ${files.length} files`);\n}\n\nexport function cleanupLockfile(\n lockfilePath: string,\n rootDirectory: string\n): void {\n const lockfile = loadLockfile(lockfilePath);\n\n // Remove entries for files that no longer exist\n let removedCount = 0;\n for (const hash in lockfile.checksums) {\n const entry = lockfile.checksums[hash];\n const absolutePath = path.resolve(rootDirectory, entry.path);\n\n if (!fs.existsSync(absolutePath)) {\n delete lockfile.checksums[hash];\n removedCount++;\n }\n }\n\n if (removedCount > 0) {\n saveLockfile(lockfilePath, lockfile);\n logger.debugMessage(\n `Cleaned up ${removedCount} stale entries from lockfile`\n );\n }\n}\n"]}
1
+ {"version":3,"file":"lockfile.js","sourceRoot":"/","sources":["utils/lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAajD,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,IAAI,CAAC;QACH,MAAM,O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C,CAAC;QAE7D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAChC,YAAY,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,YAAY,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACrC,MAAM,CAAC,YAAY,CACjB,cAAc,YAAY,8BAA8B,CACzD,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../logging/logger.js';\n\nexport const LOCKFILE_VERSION = '1.0.0';\nexport const LOCKFILE_NAME = 'locadex-lock.json';\n\nexport interface LockfileEntry {\n path: string;\n lastModified: number;\n}\n\nexport interface Lockfile {\n checksums: Record<string, LockfileEntry>; // checksum -> entry mapping\n version: string;\n updatedAt: string;\n}\n\nexport function calculateFileHash(filePath: string): string {\n try {\n const content = fs.readFileSync(filePath, 'utf8');\n return crypto.createHash('md5').update(content).digest('hex');\n } catch (error) {\n logger.debugMessage(`Failed to calculate hash for ${filePath}: ${error}`);\n return '';\n }\n}\n\nexport function loadLockfile(lockfilePath: string): Lockfile {\n try {\n if (!fs.existsSync(lockfilePath)) {\n return {\n checksums: {},\n version: '1.0.0',\n updatedAt: new Date().toISOString(),\n };\n }\n\n const content = fs.readFileSync(lockfilePath, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n logger.debugMessage(`Failed to load lockfile ${lockfilePath}: ${error}`);\n return {\n checksums: {},\n version: '1.0.0',\n updatedAt: new Date().toISOString(),\n };\n }\n}\n\nexport function saveLockfile(lockfilePath: string, lockfile: Lockfile): void {\n try {\n lockfile.updatedAt = new Date().toISOString();\n fs.writeFileSync(lockfilePath, JSON.stringify(lockfile, null, 2));\n } catch (error) {\n logger.debugMessage(`Failed to save lockfile ${lockfilePath}: ${error}`);\n }\n}\n\nexport function getChangedFiles(\n files: string[],\n lockfilePath: string\n): string[] {\n const lockfile = loadLockfile(lockfilePath);\n const changedFiles: string[] = [];\n\n for (const filePath of files) {\n const currentHash = calculateFileHash(filePath);\n\n if (!currentHash) {\n // Skip files that can't be hashed (likely don't exist or can't be read)\n continue;\n }\n\n // Check if this content hash exists in the lockfile\n const lockfileEntry = lockfile.checksums[currentHash];\n\n if (!lockfileEntry) {\n // Content hash not found, this is new or changed content\n changedFiles.push(filePath);\n }\n // If hash exists, content hasn't changed regardless of file path\n }\n\n logger.debugMessage(\n `Found ${changedFiles.length} changed files out of ${files.length} total files`\n );\n\n return changedFiles;\n}\n\nexport function updateLockfile(\n files: string[],\n lockfilePath: string,\n rootDirectory: string\n): void {\n const lockfile = loadLockfile(lockfilePath);\n\n // Build a map of paths to hashes for efficient lookup\n const pathToHashMap = new Map<string, string>();\n for (const [hash, entry] of Object.entries(lockfile.checksums)) {\n pathToHashMap.set(entry.path, hash);\n }\n\n for (const filePath of files) {\n const relativePath = path.relative(rootDirectory, filePath);\n const currentHash = calculateFileHash(filePath);\n\n if (!currentHash) {\n continue;\n }\n\n // Remove old hash entry for this file path (O(1) lookup and deletion)\n const oldHash = pathToHashMap.get(relativePath);\n if (oldHash) {\n delete lockfile.checksums[oldHash];\n }\n\n const stats = fs.statSync(filePath);\n // Use hash as key, store current path and metadata\n lockfile.checksums[currentHash] = {\n path: relativePath,\n lastModified: stats.mtime.getTime(),\n };\n\n // Update the path-to-hash mapping\n pathToHashMap.set(relativePath, currentHash);\n }\n\n saveLockfile(lockfilePath, lockfile);\n logger.debugMessage(`Updated lockfile with ${files.length} files`);\n}\n\nexport function cleanupLockfile(\n lockfilePath: string,\n rootDirectory: string\n): void {\n const lockfile = loadLockfile(lockfilePath);\n\n // Remove entries for files that no longer exist\n let removedCount = 0;\n for (const hash in lockfile.checksums) {\n const entry = lockfile.checksums[hash];\n const absolutePath = path.resolve(rootDirectory, entry.path);\n\n if (!fs.existsSync(absolutePath)) {\n delete lockfile.checksums[hash];\n removedCount++;\n }\n }\n\n if (removedCount > 0) {\n saveLockfile(lockfilePath, lockfile);\n logger.debugMessage(\n `Cleaned up ${removedCount} stale entries from lockfile`\n );\n }\n}\n"]}
@@ -77,6 +77,7 @@ const MyComponent = () => {
77
77
  - This is the classic dictionary approach. It separates content from implementation context.
78
78
  - **Use sparingly** - only use this approach when content reuse across components justifies the separation.
79
79
  - Additionally, this approach may be used to internationalize complex strings that are both logically functional and are also displayed in UI.
80
+ - If you use this approach, your dictionary entries must be stored in a filed called `dictionary.json` in the root of the project. (or in `src/dictionary.json` if there is a `src` directory). `dictionary.js` and `dictionary.ts` are also valid.
80
81
 
81
82
  **Dictionary structure**:
82
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locadex",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "An AI agent for internationalization",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "dependency-tree": "^11.1.1",
25
25
  "dotenv": "^16.4.5",
26
26
  "express": "^5.1.0",
27
- "gtx-cli": "^1.2.27",
27
+ "gtx-cli": "^1.2.28",
28
28
  "micromatch": "^4.0.8",
29
29
  "posthog-node": "^4.18.0"
30
30
  },
@@ -15,7 +15,10 @@ jobs:
15
15
  steps:
16
16
  - name: Checkout repository
17
17
  uses: actions/checkout@v4
18
+ - name: Install dependencies
19
+ run: |
20
+ [packageManager install command]
18
21
  - name: Run Locadex
19
- uses: generaltranslation/locadex@v0.1.1
22
+ uses: generaltranslation/locadex@v0
20
23
  with:
21
- api_key: \${{ secrets.LOCADEX_API_KEY }}
24
+ api_key: ${{ secrets.LOCADEX_API_KEY }}