gt 2.14.35 → 2.14.36

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.
Files changed (429) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/api/collectUserEditDiffs.js +112 -155
  3. package/dist/api/collectUserEditDiffs.js.map +1 -0
  4. package/dist/api/downloadFileBatch.js +164 -241
  5. package/dist/api/downloadFileBatch.js.map +1 -0
  6. package/dist/api/saveLocalEdits.js +37 -41
  7. package/dist/api/saveLocalEdits.js.map +1 -0
  8. package/dist/bin/bin-entry.js +17 -7
  9. package/dist/bin/bin-entry.js.map +1 -0
  10. package/dist/bin/bin-main.js +43 -61
  11. package/dist/bin/bin-main.js.map +1 -0
  12. package/dist/cli/base.js +382 -497
  13. package/dist/cli/base.js.map +1 -0
  14. package/dist/cli/commands/download.js +41 -49
  15. package/dist/cli/commands/download.js.map +1 -0
  16. package/dist/cli/commands/enqueue.js +26 -25
  17. package/dist/cli/commands/enqueue.js.map +1 -0
  18. package/dist/cli/commands/setupProject.js +33 -36
  19. package/dist/cli/commands/setupProject.js.map +1 -0
  20. package/dist/cli/commands/stage.js +53 -61
  21. package/dist/cli/commands/stage.js.map +1 -0
  22. package/dist/cli/commands/translate.js +75 -112
  23. package/dist/cli/commands/translate.js.map +1 -0
  24. package/dist/cli/commands/upload.js +185 -213
  25. package/dist/cli/commands/upload.js.map +1 -0
  26. package/dist/cli/commands/utils/validation.js +39 -34
  27. package/dist/cli/commands/utils/validation.js.map +1 -0
  28. package/dist/cli/flags.js +35 -62
  29. package/dist/cli/flags.js.map +1 -0
  30. package/dist/cli/inline.js +112 -137
  31. package/dist/cli/inline.js.map +1 -0
  32. package/dist/cli/next.js +17 -12
  33. package/dist/cli/next.js.map +1 -0
  34. package/dist/cli/node.js +19 -15
  35. package/dist/cli/node.js.map +1 -0
  36. package/dist/cli/python.js +13 -8
  37. package/dist/cli/python.js.map +1 -0
  38. package/dist/cli/react.js +61 -78
  39. package/dist/cli/react.js.map +1 -0
  40. package/dist/config/defaults.js +16 -11
  41. package/dist/config/defaults.js.map +1 -0
  42. package/dist/config/generateSettings.js +167 -269
  43. package/dist/config/generateSettings.js.map +1 -0
  44. package/dist/config/optionPresets.js +78 -96
  45. package/dist/config/optionPresets.js.map +1 -0
  46. package/dist/config/resolveConfig.js +27 -32
  47. package/dist/config/resolveConfig.js.map +1 -0
  48. package/dist/config/utils.js +7 -3
  49. package/dist/config/utils.js.map +1 -0
  50. package/dist/config/validateSettings.js +19 -30
  51. package/dist/config/validateSettings.js.map +1 -0
  52. package/dist/console/colors.js +18 -13
  53. package/dist/console/colors.js.map +1 -0
  54. package/dist/console/displayTranslateSummary.js +40 -37
  55. package/dist/console/displayTranslateSummary.js.map +1 -0
  56. package/dist/console/formatting.js +8 -5
  57. package/dist/console/formatting.js.map +1 -0
  58. package/dist/console/index.d.ts +11 -9
  59. package/dist/console/index.js +53 -50
  60. package/dist/console/index.js.map +1 -0
  61. package/dist/console/inkFields.d.ts +23 -0
  62. package/dist/console/inkFields.js +87 -0
  63. package/dist/console/inkFields.js.map +1 -0
  64. package/dist/console/inkLayout.d.ts +7 -0
  65. package/dist/console/inkLayout.js +139 -0
  66. package/dist/console/inkLayout.js.map +1 -0
  67. package/dist/console/inkLocaleData.d.ts +4 -0
  68. package/dist/console/inkLocaleData.js +32 -0
  69. package/dist/console/inkLocaleData.js.map +1 -0
  70. package/dist/console/inkPrompts.d.ts +8 -0
  71. package/dist/console/inkPrompts.js +496 -0
  72. package/dist/console/inkPrompts.js.map +1 -0
  73. package/dist/console/inkSession.d.ts +3 -0
  74. package/dist/console/inkSession.js +42 -0
  75. package/dist/console/inkSession.js.map +1 -0
  76. package/dist/console/inkTerminal.d.ts +4 -0
  77. package/dist/console/inkTerminal.js +15 -0
  78. package/dist/console/inkTerminal.js.map +1 -0
  79. package/dist/console/inkTypes.d.ts +66 -0
  80. package/dist/console/inkTypes.js +1 -0
  81. package/dist/console/inkUtils.d.ts +24 -0
  82. package/dist/console/inkUtils.js +87 -0
  83. package/dist/console/inkUtils.js.map +1 -0
  84. package/dist/console/logger.js +209 -249
  85. package/dist/console/logger.js.map +1 -0
  86. package/dist/console/logging.d.ts +14 -0
  87. package/dist/console/logging.js +203 -162
  88. package/dist/console/logging.js.map +1 -0
  89. package/dist/console/promptParsing.d.ts +5 -0
  90. package/dist/console/promptParsing.js +28 -0
  91. package/dist/console/promptParsing.js.map +1 -0
  92. package/dist/console/terminalSession.d.ts +5 -0
  93. package/dist/console/terminalSession.js +38 -0
  94. package/dist/console/terminalSession.js.map +1 -0
  95. package/dist/extraction/index.js +3 -2
  96. package/dist/extraction/mapToUpdates.js +19 -18
  97. package/dist/extraction/mapToUpdates.js.map +1 -0
  98. package/dist/extraction/postProcess.js +68 -86
  99. package/dist/extraction/postProcess.js.map +1 -0
  100. package/dist/formats/files/aggregateFiles.js +223 -304
  101. package/dist/formats/files/aggregateFiles.js.map +1 -0
  102. package/dist/formats/files/collectFiles.js +53 -54
  103. package/dist/formats/files/collectFiles.js.map +1 -0
  104. package/dist/formats/files/convertToFileTranslationData.js +21 -19
  105. package/dist/formats/files/convertToFileTranslationData.js.map +1 -0
  106. package/dist/formats/files/fileMapping.js +82 -119
  107. package/dist/formats/files/fileMapping.js.map +1 -0
  108. package/dist/formats/files/preprocess/mdx.js +15 -12
  109. package/dist/formats/files/preprocess/mdx.js.map +1 -0
  110. package/dist/formats/files/preprocess/mintlify.js +15 -13
  111. package/dist/formats/files/preprocess/mintlify.js.map +1 -0
  112. package/dist/formats/files/preprocessContent.js +20 -21
  113. package/dist/formats/files/preprocessContent.js.map +1 -0
  114. package/dist/formats/files/save.js +18 -15
  115. package/dist/formats/files/save.js.map +1 -0
  116. package/dist/formats/files/supportedFiles.js +27 -22
  117. package/dist/formats/files/supportedFiles.js.map +1 -0
  118. package/dist/formats/files/transformFormat.js +93 -100
  119. package/dist/formats/files/transformFormat.js.map +1 -0
  120. package/dist/formats/json/extractJson.js +83 -110
  121. package/dist/formats/json/extractJson.js.map +1 -0
  122. package/dist/formats/json/flattenJson.js +41 -48
  123. package/dist/formats/json/flattenJson.js.map +1 -0
  124. package/dist/formats/json/jsonPath.js +20 -15
  125. package/dist/formats/json/jsonPath.js.map +1 -0
  126. package/dist/formats/json/jsonPointer.js +17 -17
  127. package/dist/formats/json/jsonPointer.js.map +1 -0
  128. package/dist/formats/json/mergeJson.js +230 -371
  129. package/dist/formats/json/mergeJson.js.map +1 -0
  130. package/dist/formats/json/parseJson.js +74 -111
  131. package/dist/formats/json/parseJson.js.map +1 -0
  132. package/dist/formats/json/transformJson.js +53 -61
  133. package/dist/formats/json/transformJson.js.map +1 -0
  134. package/dist/formats/json/utils.js +158 -187
  135. package/dist/formats/json/utils.js.map +1 -0
  136. package/dist/formats/parseKeyedMetadata.js +85 -106
  137. package/dist/formats/parseKeyedMetadata.js.map +1 -0
  138. package/dist/formats/utils.js +13 -23
  139. package/dist/formats/utils.js.map +1 -0
  140. package/dist/formats/yaml/extractYaml.js +32 -31
  141. package/dist/formats/yaml/extractYaml.js.map +1 -0
  142. package/dist/formats/yaml/mergeYaml.js +43 -60
  143. package/dist/formats/yaml/mergeYaml.js.map +1 -0
  144. package/dist/formats/yaml/parseYaml.js +34 -23
  145. package/dist/formats/yaml/parseYaml.js.map +1 -0
  146. package/dist/formats/yaml/utils.js +19 -21
  147. package/dist/formats/yaml/utils.js.map +1 -0
  148. package/dist/fs/clearLocaleDirs.js +82 -114
  149. package/dist/fs/clearLocaleDirs.js.map +1 -0
  150. package/dist/fs/config/downloadedVersions.js +174 -188
  151. package/dist/fs/config/downloadedVersions.js.map +1 -0
  152. package/dist/fs/config/loadConfig.js +12 -8
  153. package/dist/fs/config/loadConfig.js.map +1 -0
  154. package/dist/fs/config/parseFilesConfig.js +166 -227
  155. package/dist/fs/config/parseFilesConfig.js.map +1 -0
  156. package/dist/fs/config/setupConfig.js +43 -52
  157. package/dist/fs/config/setupConfig.js.map +1 -0
  158. package/dist/fs/config/updateConfig.js +44 -56
  159. package/dist/fs/config/updateConfig.js.map +1 -0
  160. package/dist/fs/config/updateVersions.js +27 -28
  161. package/dist/fs/config/updateVersions.js.map +1 -0
  162. package/dist/fs/copyFile.js +33 -37
  163. package/dist/fs/copyFile.js.map +1 -0
  164. package/dist/fs/createLoadTranslationsFile.js +32 -48
  165. package/dist/fs/createLoadTranslationsFile.js.map +1 -0
  166. package/dist/fs/determineFramework/detectPythonLibrary.js +30 -34
  167. package/dist/fs/determineFramework/detectPythonLibrary.js.map +1 -0
  168. package/dist/fs/determineFramework/index.js +46 -64
  169. package/dist/fs/determineFramework/index.js.map +1 -0
  170. package/dist/fs/determineFramework/matchPyprojectDependency.js +65 -78
  171. package/dist/fs/determineFramework/matchPyprojectDependency.js.map +1 -0
  172. package/dist/fs/determineFramework/matchRequirementsTxtDependency.js +21 -19
  173. package/dist/fs/determineFramework/matchRequirementsTxtDependency.js.map +1 -0
  174. package/dist/fs/determineFramework/matchSetupPyDependency.js +60 -81
  175. package/dist/fs/determineFramework/matchSetupPyDependency.js.map +1 -0
  176. package/dist/fs/determineFramework/resolveGtDependency.js +15 -15
  177. package/dist/fs/determineFramework/resolveGtDependency.js.map +1 -0
  178. package/dist/fs/findFilepath.js +63 -78
  179. package/dist/fs/findFilepath.js.map +1 -0
  180. package/dist/fs/loadJSON.js +18 -15
  181. package/dist/fs/loadJSON.js.map +1 -0
  182. package/dist/fs/matchFiles.js +12 -7
  183. package/dist/fs/matchFiles.js.map +1 -0
  184. package/dist/fs/saveJSON.js +10 -6
  185. package/dist/fs/saveJSON.js.map +1 -0
  186. package/dist/fs/utils.js +19 -15
  187. package/dist/fs/utils.js.map +1 -0
  188. package/dist/functions.d.ts +2 -1
  189. package/dist/functions.js +3 -6
  190. package/dist/generated/version.d.ts +1 -1
  191. package/dist/generated/version.js +6 -2
  192. package/dist/generated/version.js.map +1 -0
  193. package/dist/git/branches.js +77 -83
  194. package/dist/git/branches.js.map +1 -0
  195. package/dist/hooks/postProcess.js +97 -114
  196. package/dist/hooks/postProcess.js.map +1 -0
  197. package/dist/index.js +23 -31
  198. package/dist/index.js.map +1 -0
  199. package/dist/locadex/setupFlow.js +11 -8
  200. package/dist/locadex/setupFlow.js.map +1 -0
  201. package/dist/main.js +17 -7
  202. package/dist/main.js.map +1 -0
  203. package/dist/next/config/parseNextConfig.js +32 -51
  204. package/dist/next/config/parseNextConfig.js.map +1 -0
  205. package/dist/next/jsx/utils.js +25 -37
  206. package/dist/next/jsx/utils.js.map +1 -0
  207. package/dist/next/parse/handleInitGT.js +87 -154
  208. package/dist/next/parse/handleInitGT.js.map +1 -0
  209. package/dist/next/parse/wrapContent.js +136 -158
  210. package/dist/next/parse/wrapContent.js.map +1 -0
  211. package/dist/python/parse/createPythonInlineUpdates.js +36 -33
  212. package/dist/python/parse/createPythonInlineUpdates.js.map +1 -0
  213. package/dist/react/config/createESBuildConfig.js +115 -115
  214. package/dist/react/config/createESBuildConfig.js.map +1 -0
  215. package/dist/react/jsx/evaluateJsx.js +90 -124
  216. package/dist/react/jsx/evaluateJsx.js.map +1 -0
  217. package/dist/react/jsx/utils/buildImportMap.js +24 -28
  218. package/dist/react/jsx/utils/buildImportMap.js.map +1 -0
  219. package/dist/react/jsx/utils/constants.js +79 -87
  220. package/dist/react/jsx/utils/constants.js.map +1 -0
  221. package/dist/react/jsx/utils/extractSourceCode.js +36 -37
  222. package/dist/react/jsx/utils/extractSourceCode.js.map +1 -0
  223. package/dist/react/jsx/utils/getCalleeNameFromExpression.js +30 -30
  224. package/dist/react/jsx/utils/getCalleeNameFromExpression.js.map +1 -0
  225. package/dist/react/jsx/utils/getPathsAndAliases.js +70 -105
  226. package/dist/react/jsx/utils/getPathsAndAliases.js.map +1 -0
  227. package/dist/react/jsx/utils/isNumberLiteral.js +13 -11
  228. package/dist/react/jsx/utils/isNumberLiteral.js.map +1 -0
  229. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +103 -148
  230. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js.map +1 -0
  231. package/dist/react/jsx/utils/jsxParsing/autoInsertion.js +305 -389
  232. package/dist/react/jsx/utils/jsxParsing/autoInsertion.js.map +1 -0
  233. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +122 -193
  234. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js.map +1 -0
  235. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +50 -64
  236. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js.map +1 -0
  237. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +41 -68
  238. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js.map +1 -0
  239. package/dist/react/jsx/utils/jsxParsing/parseJsx.js +760 -1107
  240. package/dist/react/jsx/utils/jsxParsing/parseJsx.js.map +1 -0
  241. package/dist/react/jsx/utils/jsxParsing/parseTProps.js +35 -71
  242. package/dist/react/jsx/utils/jsxParsing/parseTProps.js.map +1 -0
  243. package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +39 -58
  244. package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js.map +1 -0
  245. package/dist/react/jsx/utils/jsxParsing/types.js +10 -24
  246. package/dist/react/jsx/utils/jsxParsing/types.js.map +1 -0
  247. package/dist/react/jsx/utils/mapAttributeName.js +13 -13
  248. package/dist/react/jsx/utils/mapAttributeName.js.map +1 -0
  249. package/dist/react/jsx/utils/parseAst.js +142 -272
  250. package/dist/react/jsx/utils/parseAst.js.map +1 -0
  251. package/dist/react/jsx/utils/parseString.js +726 -1090
  252. package/dist/react/jsx/utils/parseString.js.map +1 -0
  253. package/dist/react/jsx/utils/parseStringFunction.js +274 -401
  254. package/dist/react/jsx/utils/parseStringFunction.js.map +1 -0
  255. package/dist/react/jsx/utils/resolveImportPath.js +104 -108
  256. package/dist/react/jsx/utils/resolveImportPath.js.map +1 -0
  257. package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js +18 -24
  258. package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js.map +1 -0
  259. package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js +412 -579
  260. package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js.map +1 -0
  261. package/dist/react/jsx/utils/stringParsing/derivation/index.js +57 -67
  262. package/dist/react/jsx/utils/stringParsing/derivation/index.js.map +1 -0
  263. package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js +26 -36
  264. package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js.map +1 -0
  265. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js +29 -24
  266. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js.map +1 -0
  267. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js +34 -32
  268. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js.map +1 -0
  269. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +80 -117
  270. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js.map +1 -0
  271. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js +24 -19
  272. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js.map +1 -0
  273. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +18 -21
  274. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js.map +1 -0
  275. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +45 -50
  276. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js.map +1 -0
  277. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +54 -59
  278. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js.map +1 -0
  279. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +56 -69
  280. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js.map +1 -0
  281. package/dist/react/jsx/utils/validateStringFunction.js +21 -29
  282. package/dist/react/jsx/utils/validateStringFunction.js.map +1 -0
  283. package/dist/react/jsx/wrapJsx.js +192 -375
  284. package/dist/react/jsx/wrapJsx.js.map +1 -0
  285. package/dist/react/parse/addVitePlugin/index.js +40 -34
  286. package/dist/react/parse/addVitePlugin/index.js.map +1 -0
  287. package/dist/react/parse/addVitePlugin/installCompiler.js +18 -20
  288. package/dist/react/parse/addVitePlugin/installCompiler.js.map +1 -0
  289. package/dist/react/parse/addVitePlugin/updateViteConfig.js +107 -111
  290. package/dist/react/parse/addVitePlugin/updateViteConfig.js.map +1 -0
  291. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +23 -26
  292. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js.map +1 -0
  293. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +29 -43
  294. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js.map +1 -0
  295. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +70 -104
  296. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js.map +1 -0
  297. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +23 -29
  298. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js.map +1 -0
  299. package/dist/react/parse/createDictionaryUpdates.js +121 -185
  300. package/dist/react/parse/createDictionaryUpdates.js.map +1 -0
  301. package/dist/react/parse/createInlineUpdates.js +123 -139
  302. package/dist/react/parse/createInlineUpdates.js.map +1 -0
  303. package/dist/react/parse/wrapContent.js +131 -156
  304. package/dist/react/parse/wrapContent.js.map +1 -0
  305. package/dist/react/utils/flattenDictionary.js +55 -70
  306. package/dist/react/utils/flattenDictionary.js.map +1 -0
  307. package/dist/react/utils/getEntryAndMetadata.js +14 -10
  308. package/dist/react/utils/getEntryAndMetadata.js.map +1 -0
  309. package/dist/react/utils/getVariableName.js +36 -33
  310. package/dist/react/utils/getVariableName.js.map +1 -0
  311. package/dist/setup/detectFramework.js +85 -102
  312. package/dist/setup/detectFramework.js.map +1 -0
  313. package/dist/setup/frameworkUtils.js +17 -28
  314. package/dist/setup/frameworkUtils.js.map +1 -0
  315. package/dist/setup/userInput.js +24 -31
  316. package/dist/setup/userInput.js.map +1 -0
  317. package/dist/setup/wizard.js +141 -143
  318. package/dist/setup/wizard.js.map +1 -0
  319. package/dist/state/mintlifyRefMap.js +12 -9
  320. package/dist/state/mintlifyRefMap.js.map +1 -0
  321. package/dist/state/recentDownloads.js +26 -23
  322. package/dist/state/recentDownloads.js.map +1 -0
  323. package/dist/state/translateWarnings.js +17 -8
  324. package/dist/state/translateWarnings.js.map +1 -0
  325. package/dist/translation/parse.js +77 -98
  326. package/dist/translation/parse.js.map +1 -0
  327. package/dist/translation/stage.js +28 -43
  328. package/dist/translation/stage.js.map +1 -0
  329. package/dist/translation/validate.js +68 -91
  330. package/dist/translation/validate.js.map +1 -0
  331. package/dist/types/libraries.js +93 -91
  332. package/dist/types/libraries.js.map +1 -0
  333. package/dist/types/parsing.js +19 -10
  334. package/dist/types/parsing.js.map +1 -0
  335. package/dist/utils/addExplicitAnchorIds.js +270 -389
  336. package/dist/utils/addExplicitAnchorIds.js.map +1 -0
  337. package/dist/utils/calculateTimeoutMs.js +11 -6
  338. package/dist/utils/calculateTimeoutMs.js.map +1 -0
  339. package/dist/utils/constants.js +15 -12
  340. package/dist/utils/constants.js.map +1 -0
  341. package/dist/utils/credentials.js +67 -114
  342. package/dist/utils/credentials.js.map +1 -0
  343. package/dist/utils/fetch.js +22 -20
  344. package/dist/utils/fetch.js.map +1 -0
  345. package/dist/utils/flattenJsonFiles.js +27 -34
  346. package/dist/utils/flattenJsonFiles.js.map +1 -0
  347. package/dist/utils/gitDiff.js +30 -32
  348. package/dist/utils/gitDiff.js.map +1 -0
  349. package/dist/utils/gt.js +7 -2
  350. package/dist/utils/gt.js.map +1 -0
  351. package/dist/utils/hash.js +14 -9
  352. package/dist/utils/hash.js.map +1 -0
  353. package/dist/utils/headers.js +10 -13
  354. package/dist/utils/headers.js.map +1 -0
  355. package/dist/utils/installPackage.js +70 -75
  356. package/dist/utils/installPackage.js.map +1 -0
  357. package/dist/utils/localizeRelativeAssets.js +114 -157
  358. package/dist/utils/localizeRelativeAssets.js.map +1 -0
  359. package/dist/utils/localizeStaticImports.js +229 -371
  360. package/dist/utils/localizeStaticImports.js.map +1 -0
  361. package/dist/utils/localizeStaticUrls.js +241 -424
  362. package/dist/utils/localizeStaticUrls.js.map +1 -0
  363. package/dist/utils/mintlifyTitleFallback.js +64 -72
  364. package/dist/utils/mintlifyTitleFallback.js.map +1 -0
  365. package/dist/utils/monorepoVersionCheck.js +177 -215
  366. package/dist/utils/monorepoVersionCheck.js.map +1 -0
  367. package/dist/utils/packageInfo.js +17 -16
  368. package/dist/utils/packageInfo.js.map +1 -0
  369. package/dist/utils/packageJson.js +51 -66
  370. package/dist/utils/packageJson.js.map +1 -0
  371. package/dist/utils/packageManager.js +237 -260
  372. package/dist/utils/packageManager.js.map +1 -0
  373. package/dist/utils/parse/needsCJS.js +36 -69
  374. package/dist/utils/parse/needsCJS.js.map +1 -0
  375. package/dist/utils/persistPostprocessHashes.js +30 -32
  376. package/dist/utils/persistPostprocessHashes.js.map +1 -0
  377. package/dist/utils/processAnchorIds.js +32 -54
  378. package/dist/utils/processAnchorIds.js.map +1 -0
  379. package/dist/utils/processOpenApi.js +469 -578
  380. package/dist/utils/processOpenApi.js.map +1 -0
  381. package/dist/utils/resolveMintlifyRefs.js +89 -105
  382. package/dist/utils/resolveMintlifyRefs.js.map +1 -0
  383. package/dist/utils/resolvePublish.js +46 -54
  384. package/dist/utils/resolvePublish.js.map +1 -0
  385. package/dist/utils/sanitizeFileContent.js +20 -27
  386. package/dist/utils/sanitizeFileContent.js.map +1 -0
  387. package/dist/utils/sharedStaticAssets.js +248 -366
  388. package/dist/utils/sharedStaticAssets.js.map +1 -0
  389. package/dist/utils/splitMintlifyLanguageRefs.js +208 -282
  390. package/dist/utils/splitMintlifyLanguageRefs.js.map +1 -0
  391. package/dist/utils/validateMdx.js +26 -23
  392. package/dist/utils/validateMdx.js.map +1 -0
  393. package/dist/utils/wrapPlainUrls.js +58 -70
  394. package/dist/utils/wrapPlainUrls.js.map +1 -0
  395. package/dist/workflows/download.js +92 -126
  396. package/dist/workflows/download.js.map +1 -0
  397. package/dist/workflows/enqueue.js +47 -54
  398. package/dist/workflows/enqueue.js.map +1 -0
  399. package/dist/workflows/publish.js +29 -29
  400. package/dist/workflows/publish.js.map +1 -0
  401. package/dist/workflows/setupProject.js +39 -40
  402. package/dist/workflows/setupProject.js.map +1 -0
  403. package/dist/workflows/stage.js +61 -65
  404. package/dist/workflows/stage.js.map +1 -0
  405. package/dist/workflows/steps/BranchStep.js +118 -163
  406. package/dist/workflows/steps/BranchStep.js.map +1 -0
  407. package/dist/workflows/steps/DownloadStep.js +107 -137
  408. package/dist/workflows/steps/DownloadStep.js.map +1 -0
  409. package/dist/workflows/steps/EnqueueStep.js +32 -32
  410. package/dist/workflows/steps/EnqueueStep.js.map +1 -0
  411. package/dist/workflows/steps/PollJobsStep.js +208 -292
  412. package/dist/workflows/steps/PollJobsStep.js.map +1 -0
  413. package/dist/workflows/steps/PublishStep.js +33 -38
  414. package/dist/workflows/steps/PublishStep.js.map +1 -0
  415. package/dist/workflows/steps/SetupStep.js +71 -72
  416. package/dist/workflows/steps/SetupStep.js.map +1 -0
  417. package/dist/workflows/steps/TagStep.js +39 -44
  418. package/dist/workflows/steps/TagStep.js.map +1 -0
  419. package/dist/workflows/steps/UploadSourcesStep.js +108 -140
  420. package/dist/workflows/steps/UploadSourcesStep.js.map +1 -0
  421. package/dist/workflows/steps/UploadTranslationsStep.js +61 -71
  422. package/dist/workflows/steps/UploadTranslationsStep.js.map +1 -0
  423. package/dist/workflows/steps/UserEditDiffsStep.js +32 -34
  424. package/dist/workflows/steps/UserEditDiffsStep.js.map +1 -0
  425. package/dist/workflows/steps/WorkflowStep.js +6 -2
  426. package/dist/workflows/steps/WorkflowStep.js.map +1 -0
  427. package/dist/workflows/upload.js +45 -46
  428. package/dist/workflows/upload.js.map +1 -0
  429. package/package.json +14 -7
package/dist/cli/base.js CHANGED
@@ -1,500 +1,385 @@
1
- import { DEFAULT_TRANSLATIONS_DIR, DEFAULT_VITE_TRANSLATIONS_DIR, } from '../utils/constants.js';
2
- import { createOrUpdateConfig } from '../fs/config/setupConfig.js';
3
- import findFilepath from '../fs/findFilepath.js';
4
- import { displayHeader, promptText, logErrorAndExit, promptConfirm, promptMultiSelect, promptSelect, } from '../console/logging.js';
5
- import { logger } from '../console/logger.js';
6
- import path from 'node:path';
7
- import fs from 'node:fs';
8
- import { generateSettings } from '../config/generateSettings.js';
9
- import chalk from 'chalk';
10
- import { FILE_EXT_TO_EXT_LABEL } from '../formats/files/supportedFiles.js';
11
- import { handleSetupReactCommand } from '../setup/wizard.js';
12
- import { isPackageInstalled, searchForPackageJson, } from '../utils/packageJson.js';
13
- import { getDesiredLocales } from '../setup/userInput.js';
14
- import { installPackage } from '../utils/installPackage.js';
15
- import { getPackageManager } from '../utils/packageManager.js';
16
- import { retrieveCredentials, setCredentials } from '../utils/credentials.js';
17
- import { areCredentialsSet } from '../utils/credentials.js';
18
- import { upload } from './commands/upload.js';
19
- import { attachSharedFlags, attachTranslateFlags } from './flags.js';
20
- import { handleStage } from './commands/stage.js';
21
- import { handleSetupProject } from './commands/setupProject.js';
22
- import { handleDownload } from './commands/download.js';
23
- import { handleTranslate, postProcessTranslations, } from './commands/translate.js';
24
- import { getNeedsPostprocessing, clearDownloaded, } from '../state/recentDownloads.js';
25
- import { clearWarnings } from '../state/translateWarnings.js';
26
- import { displayTranslateSummary } from '../console/displayTranslateSummary.js';
27
- import updateConfig from '../fs/config/updateConfig.js';
28
- import { createLoadTranslationsFile } from '../fs/createLoadTranslationsFile.js';
29
- import { saveLocalEdits } from '../api/saveLocalEdits.js';
30
- import processSharedStaticAssets, { mirrorAssetsToLocales, } from '../utils/sharedStaticAssets.js';
31
- import { setupLocadex } from '../locadex/setupFlow.js';
32
- import { detectFramework } from '../setup/detectFramework.js';
33
- import { getFrameworkDisplayName, getReactFrameworkLibrary, } from '../setup/frameworkUtils.js';
34
- import { INLINE_LIBRARIES } from '../types/libraries.js';
35
- import { handleEnqueue } from './commands/enqueue.js';
36
- import { splitMintlifyLanguageRefs } from '../utils/splitMintlifyLanguageRefs.js';
37
- export class BaseCLI {
38
- library;
39
- additionalModules;
40
- program;
41
- // Constructor is shared amongst all CLI class types
42
- constructor(program, library, additionalModules) {
43
- this.program = program;
44
- this.library = library;
45
- this.additionalModules = additionalModules || [];
46
- this.program.option('--skip-version-check', 'Skip the monorepo GT package version consistency check');
47
- this.setupInitCommand();
48
- this.setupConfigureCommand();
49
- this.setupUploadCommand();
50
- this.setupLoginCommand();
51
- this.setupSendDiffsCommand();
52
- }
53
- // Init is never called in a child class
54
- init() {
55
- this.setupSetupProjectCommand();
56
- this.setupStageCommand();
57
- this.setupTranslateCommand();
58
- this.setupDownloadCommand();
59
- this.setupEnqueueCommand();
60
- }
61
- // Execute is called by the main program
62
- execute() {
63
- // If no command is specified, run 'init'
64
- if (process.argv.length <= 2) {
65
- process.argv.push('init');
66
- }
67
- }
68
- setupSetupProjectCommand() {
69
- attachTranslateFlags(this.program
70
- .command('setup')
71
- .description('Upload source files and setup the project for translation')).action(async (initOptions) => {
72
- displayHeader('Uploading source files and setting up project...');
73
- await this.handleSetupProject(initOptions);
74
- logger.endCommand('Done!');
75
- });
76
- }
77
- setupStageCommand() {
78
- attachTranslateFlags(this.program
79
- .command('stage')
80
- .description('Submits the project to the General Translation API for translation. Translations created using this command will require human approval.')).action(async (initOptions) => {
81
- displayHeader('Staging project for translation with approval required...');
82
- await this.handleStage(initOptions);
83
- logger.endCommand('Done!');
84
- });
85
- }
86
- /**
87
- * Enqueues translations for a given set of files
88
- * @param initOptions - The options for the command
89
- * @returns The results of the command
90
- */
91
- setupEnqueueCommand() {
92
- attachTranslateFlags(this.program
93
- .command('enqueue')
94
- .description('Enqueues translations for a given set of files')).action(async (initOptions) => {
95
- displayHeader('Enqueuing translations...');
96
- await this.handleEnqueue(initOptions);
97
- logger.endCommand('Done!');
98
- });
99
- }
100
- /**
101
- * Downloads translations that were originally staged
102
- * @param initOptions - The options for the command
103
- * @returns The results of the command
104
- */
105
- setupDownloadCommand() {
106
- attachTranslateFlags(this.program
107
- .command('download')
108
- .description('Download translations that were originally staged')).action(async (initOptions) => {
109
- displayHeader('Downloading translations...');
110
- await this.handleDownload(initOptions);
111
- logger.endCommand('Done!');
112
- });
113
- }
114
- setupTranslateCommand() {
115
- attachTranslateFlags(this.program
116
- .command('translate')
117
- .description('Translate your project using General Translation')).action(async (initOptions) => {
118
- displayHeader('Starting translation...');
119
- await this.handleTranslate(initOptions);
120
- logger.endCommand('Done!');
121
- });
122
- }
123
- setupSendDiffsCommand() {
124
- attachSharedFlags(this.program
125
- .command('save-local')
126
- .description('Save local edits for all configured files by sending diffs (no translation enqueued)'))
127
- .option('--publish', 'Publish translations to the CDN', false)
128
- .action(async (initOptions) => {
129
- displayHeader('Saving local edits...');
130
- const settings = await generateSettings(initOptions, undefined, {
131
- requireConfig: true,
132
- });
133
- await saveLocalEdits(settings);
134
- logger.endCommand('Saved local edits');
135
- });
136
- }
137
- async handleSetupProject(initOptions) {
138
- const settings = await generateSettings(initOptions, undefined, {
139
- requireConfig: true,
140
- });
141
- // Preprocess shared static assets if configured (move + rewrite sources)
142
- await processSharedStaticAssets(settings);
143
- await handleSetupProject(initOptions, settings, this.library);
144
- }
145
- async handleStage(initOptions) {
146
- const settings = await generateSettings(initOptions, undefined, {
147
- requireConfig: true,
148
- });
149
- // Preprocess shared static assets if configured (move + rewrite sources)
150
- await processSharedStaticAssets(settings);
151
- if (!settings.stageTranslations) {
152
- // Update settings.stageTranslations to true
153
- settings.stageTranslations = true;
154
- await updateConfig(settings.config, {
155
- stageTranslations: true,
156
- });
157
- }
158
- await handleStage(initOptions, settings, this.library, true);
159
- }
160
- /**
161
- * Enqueues translations for a given set of files
162
- * @param initOptions - The options for the command
163
- * @returns The results of the command
164
- */
165
- async handleEnqueue(initOptions) {
166
- const settings = await generateSettings(initOptions, undefined, {
167
- requireConfig: true,
168
- });
169
- await handleEnqueue(initOptions, settings, this.library);
170
- }
171
- /**
172
- * Downloads translations that were originally staged
173
- * @param initOptions - The options for the command
174
- * @returns The results of the command
175
- */
176
- async handleDownload(initOptions) {
177
- const settings = await generateSettings(initOptions, undefined, {
178
- requireConfig: true,
179
- });
180
- await handleDownload(initOptions, settings, this.library);
181
- }
182
- async handleTranslate(initOptions) {
183
- const settings = await generateSettings(initOptions, undefined, {
184
- requireConfig: true,
185
- });
186
- // Preprocess shared static assets if configured (move + rewrite sources)
187
- await processSharedStaticAssets(settings);
188
- if (!settings.stageTranslations) {
189
- const results = await handleStage(initOptions, settings, this.library, false);
190
- if (results) {
191
- await handleTranslate(initOptions, settings, results.fileVersionData, results.jobData, results.branchData, results.publishMap);
192
- }
193
- }
194
- else {
195
- await handleDownload(initOptions, settings, this.library);
196
- }
197
- // Only postprocess files downloaded in this run
198
- const include = getNeedsPostprocessing();
199
- if (include.size > 0) {
200
- await postProcessTranslations(settings, include);
201
- }
202
- // Split Mintlify language entries into $ref files to keep docs.json small
203
- await splitMintlifyLanguageRefs(settings);
204
- // Mirror assets after translations are downloaded and locale dirs are populated
205
- await mirrorAssetsToLocales(settings);
206
- clearDownloaded();
207
- displayTranslateSummary();
208
- clearWarnings();
209
- }
210
- setupUploadCommand() {
211
- attachTranslateFlags(this.program
212
- .command('upload')
213
- .description('Upload source files and translations to the General Translation platform')).action(async (initOptions) => {
214
- displayHeader('Starting upload...');
215
- const settings = await generateSettings(initOptions, undefined, {
216
- requireConfig: true,
217
- });
218
- const options = { ...initOptions, ...settings };
219
- await this.handleUploadCommand(options);
220
- logger.endCommand('Done!');
221
- });
222
- }
223
- setupLoginCommand() {
224
- this.program
225
- .command('auth')
226
- .description('Generate General Translation API keys and project ID')
227
- .option('-c, --config <path>', 'Filepath to config file, by default gt.config.json', findFilepath(['gt.config.json']))
228
- .option('-t, --key-type <type>', 'Type of key to generate, production | development | all')
229
- .action(async (options) => {
230
- displayHeader('Authenticating with General Translation...');
231
- if (!options.keyType) {
232
- options.keyType = await promptSelect({
233
- message: 'What type of API key would you like to generate?',
234
- options: [
235
- { value: 'development', label: 'Development' },
236
- { value: 'production', label: 'Production' },
237
- { value: 'all', label: 'Both' },
238
- ],
239
- defaultValue: 'all',
240
- });
241
- }
242
- else {
243
- if (options.keyType !== 'development' &&
244
- options.keyType !== 'production' &&
245
- options.keyType !== 'all') {
246
- logErrorAndExit('Invalid key type, must be development, production, or all');
247
- }
248
- }
249
- await this.handleLoginCommand(options);
250
- logger.endCommand(`Done! ${options.keyType} keys have been generated and saved to your .env.local file.`);
251
- });
252
- }
253
- setupInitCommand() {
254
- this.program
255
- .command('init')
256
- .description('Run the setup wizard to configure your project for General Translation')
257
- .option('--src <paths...>', "Space-separated list of glob patterns containing the app's source code, by default 'src/**/*.{js,jsx,ts,tsx}' 'app/**/*.{js,jsx,ts,tsx}' 'pages/**/*.{js,jsx,ts,tsx}' 'components/**/*.{js,jsx,ts,tsx}'")
258
- .option('-c, --config <path>', 'Filepath to config file, by default gt.config.json', findFilepath(['gt.config.json']))
259
- .action(async (options) => {
260
- const settings = await generateSettings(options);
261
- displayHeader('Running setup wizard...');
262
- const framework = await detectFramework();
263
- const useAgent = await (async () => {
264
- let useAgentMessage;
265
- if (framework.name === 'mintlify') {
266
- useAgentMessage = `Mintlify project detected. Would you like to connect to GitHub so that the Locadex AI Agent can translate your project automatically?`;
267
- }
268
- if (framework.name === 'next-app') {
269
- useAgentMessage = `Next.js App Router detected. Would you like to connect to GitHub so that the Locadex AI Agent can set up your project automatically?`;
270
- }
271
- if (useAgentMessage) {
272
- return await promptConfirm({
273
- message: useAgentMessage,
274
- defaultValue: false,
275
- });
276
- }
277
- return false;
278
- })();
279
- if (useAgent) {
280
- await setupLocadex(settings);
281
- logger.endCommand('Once installed, Locadex will open a PR to your repository. See the docs for more information: https://generaltranslation.com/docs/locadex');
282
- }
283
- else {
284
- // Get framework display info for the defaults message
285
- const frameworkDisplayName = framework.type === 'react'
286
- ? getFrameworkDisplayName(framework)
287
- : null;
288
- const library = framework.type === 'react'
289
- ? getReactFrameworkLibrary(framework)
290
- : null;
291
- // Build defaults description based on detected framework
292
- const defaultTranslationsDir = framework.name === 'vite'
293
- ? DEFAULT_VITE_TRANSLATIONS_DIR
294
- : DEFAULT_TRANSLATIONS_DIR;
295
- const defaultsDescription = framework.type === 'react'
296
- ? `${library} & GTProvider, ${frameworkDisplayName}, Files saved locally in ${defaultTranslationsDir}`
297
- : `Files saved locally in ${defaultTranslationsDir}`;
298
- // Ask if user wants to use defaults
299
- const useDefaults = await promptConfirm({
300
- message: `Would you like to use the recommended General Translation defaults? ${chalk.dim(`(${defaultsDescription})`)}`,
301
- defaultValue: true,
302
- });
303
- let ranReactSetup = false;
304
- // so that people can run init in non-js projects
305
- if (framework.type === 'react') {
306
- const wrap = useDefaults
307
- ? true
308
- : await promptConfirm({
309
- message: `Would you like to install ${library} and add the GTProvider? See the docs for more information: https://generaltranslation.com/docs/react/tutorials/quickstart`,
310
- defaultValue: true,
311
- });
312
- if (wrap) {
313
- logger.info(`${chalk.yellow('[EXPERIMENTAL]')} Configuring project...`);
314
- await handleSetupReactCommand(options, framework, useDefaults);
315
- logger.endCommand(`Done! Since this wizard is experimental, please review the changes and make modifications as needed.
1
+ import { logger } from "../console/logger.js";
2
+ import { isPackageInstalled, searchForPackageJson } from "../utils/packageJson.js";
3
+ import { DEFAULT_TRANSLATIONS_DIR, DEFAULT_VITE_TRANSLATIONS_DIR } from "../utils/constants.js";
4
+ import { parseGlobPatterns } from "../console/promptParsing.js";
5
+ import { displayHeader, logErrorAndExit, promptConfirm, promptGlobPatterns, promptMultiSelect, promptSelect, promptText } from "../console/logging.js";
6
+ import findFilepath from "../fs/findFilepath.js";
7
+ import { INLINE_LIBRARIES } from "../types/libraries.js";
8
+ import { FILE_EXT_TO_EXT_LABEL } from "../formats/files/supportedFiles.js";
9
+ import { generateSettings } from "../config/generateSettings.js";
10
+ import { createOrUpdateConfig } from "../fs/config/setupConfig.js";
11
+ import { getPackageManager } from "../utils/packageManager.js";
12
+ import { installPackage } from "../utils/installPackage.js";
13
+ import { getFrameworkDisplayName, getReactFrameworkLibrary } from "../setup/frameworkUtils.js";
14
+ import { handleSetupReactCommand } from "../setup/wizard.js";
15
+ import { getDesiredLocales } from "../setup/userInput.js";
16
+ import { areCredentialsSet, retrieveCredentials, setCredentials } from "../utils/credentials.js";
17
+ import { clearWarnings } from "../state/translateWarnings.js";
18
+ import { upload } from "./commands/upload.js";
19
+ import { attachSharedFlags, attachTranslateFlags } from "./flags.js";
20
+ import updateConfig from "../fs/config/updateConfig.js";
21
+ import { handleStage } from "./commands/stage.js";
22
+ import { handleSetupProject } from "./commands/setupProject.js";
23
+ import { clearDownloaded, getNeedsPostprocessing } from "../state/recentDownloads.js";
24
+ import { handleDownload } from "./commands/download.js";
25
+ import { handleTranslate, postProcessTranslations } from "./commands/translate.js";
26
+ import { displayTranslateSummary } from "../console/displayTranslateSummary.js";
27
+ import { createLoadTranslationsFile } from "../fs/createLoadTranslationsFile.js";
28
+ import { saveLocalEdits } from "../api/saveLocalEdits.js";
29
+ import processSharedStaticAssets, { mirrorAssetsToLocales } from "../utils/sharedStaticAssets.js";
30
+ import { setupLocadex } from "../locadex/setupFlow.js";
31
+ import { detectFramework } from "../setup/detectFramework.js";
32
+ import { handleEnqueue } from "./commands/enqueue.js";
33
+ import { splitMintlifyLanguageRefs } from "../utils/splitMintlifyLanguageRefs.js";
34
+ import chalk from "chalk";
35
+ import path from "node:path";
36
+ import fs from "node:fs";
37
+ //#region src/cli/base.ts
38
+ var BaseCLI = class {
39
+ library;
40
+ additionalModules;
41
+ program;
42
+ constructor(program, library, additionalModules) {
43
+ this.program = program;
44
+ this.library = library;
45
+ this.additionalModules = additionalModules || [];
46
+ this.program.option("--skip-version-check", "Skip the monorepo GT package version consistency check");
47
+ this.setupInitCommand();
48
+ this.setupConfigureCommand();
49
+ this.setupUploadCommand();
50
+ this.setupLoginCommand();
51
+ this.setupSendDiffsCommand();
52
+ }
53
+ init() {
54
+ this.setupSetupProjectCommand();
55
+ this.setupStageCommand();
56
+ this.setupTranslateCommand();
57
+ this.setupDownloadCommand();
58
+ this.setupEnqueueCommand();
59
+ }
60
+ execute() {
61
+ if (process.argv.length <= 2) process.argv.push("init");
62
+ }
63
+ setupSetupProjectCommand() {
64
+ attachTranslateFlags(this.program.command("setup").description("Upload source files and setup the project for translation")).action(async (initOptions) => {
65
+ displayHeader("Uploading source files and setting up project...");
66
+ await this.handleSetupProject(initOptions);
67
+ logger.endCommand("Done!");
68
+ });
69
+ }
70
+ setupStageCommand() {
71
+ attachTranslateFlags(this.program.command("stage").description("Submits the project to the General Translation API for translation. Translations created using this command will require human approval.")).action(async (initOptions) => {
72
+ displayHeader("Staging project for translation with approval required...");
73
+ await this.handleStage(initOptions);
74
+ logger.endCommand("Done!");
75
+ });
76
+ }
77
+ /**
78
+ * Enqueues translations for a given set of files
79
+ * @param initOptions - The options for the command
80
+ * @returns The results of the command
81
+ */
82
+ setupEnqueueCommand() {
83
+ attachTranslateFlags(this.program.command("enqueue").description("Enqueues translations for a given set of files")).action(async (initOptions) => {
84
+ displayHeader("Enqueuing translations...");
85
+ await this.handleEnqueue(initOptions);
86
+ logger.endCommand("Done!");
87
+ });
88
+ }
89
+ /**
90
+ * Downloads translations that were originally staged
91
+ * @param initOptions - The options for the command
92
+ * @returns The results of the command
93
+ */
94
+ setupDownloadCommand() {
95
+ attachTranslateFlags(this.program.command("download").description("Download translations that were originally staged")).action(async (initOptions) => {
96
+ displayHeader("Downloading translations...");
97
+ await this.handleDownload(initOptions);
98
+ logger.endCommand("Done!");
99
+ });
100
+ }
101
+ setupTranslateCommand() {
102
+ attachTranslateFlags(this.program.command("translate").description("Translate your project using General Translation")).action(async (initOptions) => {
103
+ displayHeader("Starting translation...");
104
+ await this.handleTranslate(initOptions);
105
+ logger.endCommand("Done!");
106
+ });
107
+ }
108
+ setupSendDiffsCommand() {
109
+ attachSharedFlags(this.program.command("save-local").description("Save local edits for all configured files by sending diffs (no translation enqueued)")).option("--publish", "Publish translations to the CDN", false).action(async (initOptions) => {
110
+ displayHeader("Saving local edits...");
111
+ await saveLocalEdits(await generateSettings(initOptions, void 0, { requireConfig: true }));
112
+ logger.endCommand("Saved local edits");
113
+ });
114
+ }
115
+ async handleSetupProject(initOptions) {
116
+ const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
117
+ await processSharedStaticAssets(settings);
118
+ await handleSetupProject(initOptions, settings, this.library);
119
+ }
120
+ async handleStage(initOptions) {
121
+ const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
122
+ await processSharedStaticAssets(settings);
123
+ if (!settings.stageTranslations) {
124
+ settings.stageTranslations = true;
125
+ await updateConfig(settings.config, { stageTranslations: true });
126
+ }
127
+ await handleStage(initOptions, settings, this.library, true);
128
+ }
129
+ /**
130
+ * Enqueues translations for a given set of files
131
+ * @param initOptions - The options for the command
132
+ * @returns The results of the command
133
+ */
134
+ async handleEnqueue(initOptions) {
135
+ await handleEnqueue(initOptions, await generateSettings(initOptions, void 0, { requireConfig: true }), this.library);
136
+ }
137
+ /**
138
+ * Downloads translations that were originally staged
139
+ * @param initOptions - The options for the command
140
+ * @returns The results of the command
141
+ */
142
+ async handleDownload(initOptions) {
143
+ await handleDownload(initOptions, await generateSettings(initOptions, void 0, { requireConfig: true }), this.library);
144
+ }
145
+ async handleTranslate(initOptions) {
146
+ const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
147
+ await processSharedStaticAssets(settings);
148
+ if (!settings.stageTranslations) {
149
+ const results = await handleStage(initOptions, settings, this.library, false);
150
+ if (results) await handleTranslate(initOptions, settings, results.fileVersionData, results.jobData, results.branchData, results.publishMap);
151
+ } else await handleDownload(initOptions, settings, this.library);
152
+ const include = getNeedsPostprocessing();
153
+ if (include.size > 0) await postProcessTranslations(settings, include);
154
+ await splitMintlifyLanguageRefs(settings);
155
+ await mirrorAssetsToLocales(settings);
156
+ clearDownloaded();
157
+ displayTranslateSummary();
158
+ clearWarnings();
159
+ }
160
+ setupUploadCommand() {
161
+ attachTranslateFlags(this.program.command("upload").description("Upload source files and translations to the General Translation platform")).action(async (initOptions) => {
162
+ displayHeader("Starting upload...");
163
+ const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
164
+ const options = {
165
+ ...initOptions,
166
+ ...settings
167
+ };
168
+ await this.handleUploadCommand(options);
169
+ logger.endCommand("Done!");
170
+ });
171
+ }
172
+ setupLoginCommand() {
173
+ this.program.command("auth").description("Generate General Translation API keys and project ID").option("-c, --config <path>", "Filepath to config file, by default gt.config.json", findFilepath(["gt.config.json"])).option("-t, --key-type <type>", "Type of key to generate, production | development | all").action(async (options) => {
174
+ displayHeader("Authenticating with General Translation...");
175
+ if (!options.keyType) options.keyType = await promptSelect({
176
+ message: "What type of API key would you like to generate?",
177
+ options: [
178
+ {
179
+ value: "development",
180
+ label: "Development"
181
+ },
182
+ {
183
+ value: "production",
184
+ label: "Production"
185
+ },
186
+ {
187
+ value: "all",
188
+ label: "Both"
189
+ }
190
+ ],
191
+ defaultValue: "all"
192
+ });
193
+ else if (options.keyType !== "development" && options.keyType !== "production" && options.keyType !== "all") logErrorAndExit("Invalid key type, must be development, production, or all");
194
+ await this.handleLoginCommand(options);
195
+ logger.endCommand(`Done! ${options.keyType} keys have been generated and saved to your .env.local file.`);
196
+ });
197
+ }
198
+ setupInitCommand() {
199
+ this.program.command("init").description("Run the setup wizard to configure your project for General Translation").option("--src <paths...>", "Space-separated list of glob patterns containing the app's source code, by default 'src/**/*.{js,jsx,ts,tsx}' 'app/**/*.{js,jsx,ts,tsx}' 'pages/**/*.{js,jsx,ts,tsx}' 'components/**/*.{js,jsx,ts,tsx}'").option("-c, --config <path>", "Filepath to config file, by default gt.config.json", findFilepath(["gt.config.json"])).action(async (options) => {
200
+ const settings = await generateSettings(options);
201
+ displayHeader("Running setup wizard...");
202
+ const framework = await detectFramework();
203
+ if (await (async () => {
204
+ let useAgentMessage;
205
+ if (framework.name === "mintlify") useAgentMessage = `Mintlify project detected. Would you like to connect to GitHub so that the Locadex AI Agent can translate your project automatically?`;
206
+ if (framework.name === "next-app") useAgentMessage = `Next.js App Router detected. Would you like to connect to GitHub so that the Locadex AI Agent can set up your project automatically?`;
207
+ if (useAgentMessage) return await promptConfirm({
208
+ message: useAgentMessage,
209
+ defaultValue: false
210
+ });
211
+ return false;
212
+ })()) {
213
+ await setupLocadex(settings);
214
+ logger.endCommand("Once installed, Locadex will open a PR to your repository. See the docs for more information: https://generaltranslation.com/docs/locadex");
215
+ } else {
216
+ const frameworkDisplayName = framework.type === "react" ? getFrameworkDisplayName(framework) : null;
217
+ const library = framework.type === "react" ? getReactFrameworkLibrary(framework) : null;
218
+ const defaultTranslationsDir = framework.name === "vite" ? DEFAULT_VITE_TRANSLATIONS_DIR : DEFAULT_TRANSLATIONS_DIR;
219
+ const defaultsDescription = framework.type === "react" ? `${library} & GTProvider, ${frameworkDisplayName}, Files saved locally in ${defaultTranslationsDir}` : `Files saved locally in ${defaultTranslationsDir}`;
220
+ const useDefaults = await promptConfirm({
221
+ message: `Would you like to use the recommended General Translation defaults? ${chalk.dim(`(${defaultsDescription})`)}`,
222
+ defaultValue: true
223
+ });
224
+ let ranReactSetup = false;
225
+ if (framework.type === "react") {
226
+ if (useDefaults ? true : await promptConfirm({
227
+ message: `Would you like to install ${library} and add the GTProvider? See the docs for more information: https://generaltranslation.com/docs/react/tutorials/quickstart`,
228
+ defaultValue: true
229
+ })) {
230
+ logger.info(`${chalk.yellow("[EXPERIMENTAL]")} Configuring project...`);
231
+ await handleSetupReactCommand(options, framework, useDefaults);
232
+ logger.endCommand(`Done! Since this wizard is experimental, please review the changes and make modifications as needed.
316
233
  \nNext step: start internationalizing! See the docs for more information: https://generaltranslation.com/docs/react/tutorials/quickstart`);
317
- ranReactSetup = true;
318
- }
319
- }
320
- if (ranReactSetup) {
321
- logger.startCommand('Setting up project config...');
322
- }
323
- // Configure gt.config.json
324
- await this.handleInitCommand(ranReactSetup, useDefaults, framework.name === 'vite');
325
- logger.endCommand('Done! Check out our docs for more information on how to use General Translation: https://generaltranslation.com/docs');
326
- }
327
- });
328
- }
329
- setupConfigureCommand() {
330
- this.program
331
- .command('configure')
332
- .description('Configure your project for General Translation. This will create a gt.config.json file in your codebase.')
333
- .action(async () => {
334
- displayHeader('Configuring project...');
335
- logger.info('Welcome! This tool will help you configure your gt.config.json file. See the docs: https://generaltranslation.com/docs/cli/reference/config for more information.');
336
- // Configure gt.config.json
337
- const framework = await detectFramework();
338
- await this.handleInitCommand(false, false, framework.name === 'vite');
339
- logger.endCommand('Done! Make sure you have an API key and project ID to use General Translation. Get them on the dashboard: https://generaltranslation.com/dashboard');
340
- });
341
- }
342
- async handleUploadCommand(settings) {
343
- // dataFormat for JSONs
344
- let dataFormat;
345
- if (this.library === 'next-intl') {
346
- dataFormat = 'ICU';
347
- }
348
- else if (this.library === 'i18next') {
349
- if (this.additionalModules.includes('i18next-icu')) {
350
- dataFormat = 'ICU';
351
- }
352
- else {
353
- dataFormat = 'I18NEXT';
354
- }
355
- }
356
- else {
357
- dataFormat = 'JSX';
358
- }
359
- if (!settings.files) {
360
- return;
361
- }
362
- const { resolvedPaths: sourceFiles, placeholderPaths, transformPaths, } = settings.files;
363
- // Process all file types at once with a single call
364
- await upload(sourceFiles, placeholderPaths, transformPaths, dataFormat, settings);
365
- }
366
- // Wizard for configuring gt.config.json
367
- async handleInitCommand(ranReactSetup, useDefaults = false, isVite = false) {
368
- const { defaultLocale, locales } = await getDesiredLocales(); // Locales should still be asked for even if using defaults
369
- const packageJson = await searchForPackageJson();
370
- // Ask if using another i18n library
371
- const gtInstalled = !!packageJson &&
372
- INLINE_LIBRARIES.some((lib) => isPackageInstalled(lib, packageJson));
373
- const isUsingGT = ranReactSetup || gtInstalled;
374
- // Ask where the translations are stored
375
- const usingCDN = await (async () => {
376
- if (!isUsingGT)
377
- return false;
378
- if (useDefaults)
379
- return false; // Default to local
380
- const selectedValue = await promptSelect({
381
- message: `Would you like to save translation files locally or use the General Translation CDN to store them?`,
382
- options: [
383
- { value: 'local', label: 'Save locally' },
384
- { value: 'cdn', label: 'Use CDN' },
385
- ],
386
- defaultValue: 'local',
387
- });
388
- return selectedValue === 'cdn';
389
- })();
390
- const defaultTranslationsDir = isVite
391
- ? DEFAULT_VITE_TRANSLATIONS_DIR
392
- : DEFAULT_TRANSLATIONS_DIR;
393
- // Ask where the translations are stored
394
- const translationsDir = isUsingGT && !usingCDN
395
- ? useDefaults
396
- ? defaultTranslationsDir
397
- : await promptText({
398
- message: 'What is the path to the directory where you would like to store your translation files?',
399
- defaultValue: defaultTranslationsDir,
400
- })
401
- : null;
402
- // Determine final translations directory with fallback
403
- const finalTranslationsDir = translationsDir?.trim() || defaultTranslationsDir;
404
- if (isUsingGT && !usingCDN) {
405
- // Create loadTranslations.js file for local translations
406
- await createLoadTranslationsFile(process.cwd(), finalTranslationsDir, locales);
407
- logger.message(`Created ${chalk.cyan('loadTranslations.js')} file for local translations.
234
+ ranReactSetup = true;
235
+ }
236
+ }
237
+ if (ranReactSetup) logger.startCommand("Setting up project config...");
238
+ await this.handleInitCommand(ranReactSetup, useDefaults, framework.name === "vite");
239
+ logger.endCommand("Done! Check out our docs for more information on how to use General Translation: https://generaltranslation.com/docs");
240
+ }
241
+ });
242
+ }
243
+ setupConfigureCommand() {
244
+ this.program.command("configure").description("Configure your project for General Translation. This will create a gt.config.json file in your codebase.").action(async () => {
245
+ displayHeader("Configuring project...");
246
+ logger.info("Welcome! This tool will help you configure your gt.config.json file. See the docs: https://generaltranslation.com/docs/cli/reference/config for more information.");
247
+ const framework = await detectFramework();
248
+ await this.handleInitCommand(false, false, framework.name === "vite");
249
+ logger.endCommand("Done! Make sure you have an API key and project ID to use General Translation. Get them on the dashboard: https://generaltranslation.com/dashboard");
250
+ });
251
+ }
252
+ async handleUploadCommand(settings) {
253
+ let dataFormat;
254
+ if (this.library === "next-intl") dataFormat = "ICU";
255
+ else if (this.library === "i18next") if (this.additionalModules.includes("i18next-icu")) dataFormat = "ICU";
256
+ else dataFormat = "I18NEXT";
257
+ else dataFormat = "JSX";
258
+ if (!settings.files) return;
259
+ const { resolvedPaths: sourceFiles, placeholderPaths, transformPaths } = settings.files;
260
+ await upload(sourceFiles, placeholderPaths, transformPaths, dataFormat, settings);
261
+ }
262
+ async handleInitCommand(ranReactSetup, useDefaults = false, isVite = false) {
263
+ const { defaultLocale, locales } = await getDesiredLocales();
264
+ const packageJson = await searchForPackageJson();
265
+ const gtInstalled = !!packageJson && INLINE_LIBRARIES.some((lib) => isPackageInstalled(lib, packageJson));
266
+ const isUsingGT = ranReactSetup || gtInstalled;
267
+ const usingCDN = await (async () => {
268
+ if (!isUsingGT) return false;
269
+ if (useDefaults) return false;
270
+ return await promptSelect({
271
+ message: `Would you like to save translation files locally or use the General Translation CDN to store them?`,
272
+ options: [{
273
+ value: "local",
274
+ label: "Save locally"
275
+ }, {
276
+ value: "cdn",
277
+ label: "Use CDN"
278
+ }],
279
+ defaultValue: "local"
280
+ }) === "cdn";
281
+ })();
282
+ const defaultTranslationsDir = isVite ? DEFAULT_VITE_TRANSLATIONS_DIR : DEFAULT_TRANSLATIONS_DIR;
283
+ const finalTranslationsDir = (isUsingGT && !usingCDN ? useDefaults ? defaultTranslationsDir : await promptText({
284
+ message: "What is the path to the directory where you would like to store your translation files?",
285
+ defaultValue: defaultTranslationsDir
286
+ }) : null)?.trim() || defaultTranslationsDir;
287
+ if (isUsingGT && !usingCDN) {
288
+ await createLoadTranslationsFile(process.cwd(), finalTranslationsDir, locales);
289
+ logger.message(`Created ${chalk.cyan("loadTranslations.js")} file for local translations.
408
290
  Make sure to add this function to your app configuration.
409
291
  See https://generaltranslation.com/en/docs/next/guides/local-tx`);
410
- }
411
- const message = !isUsingGT
412
- ? 'What is the format of your language resource files? Select as many as applicable.\nAdditionally, you can translate any other files you have in your project.'
413
- : `Do you have any additional files in this project to translate? For example, Markdown files for docs. ${chalk.dim('(To continue without selecting press Enter)')}`;
414
- const fileExtensions = useDefaults && isUsingGT
415
- ? [] // Skip for GT projects when using defaults
416
- : await promptMultiSelect({
417
- message,
418
- options: [
419
- { value: 'json', label: FILE_EXT_TO_EXT_LABEL.json },
420
- { value: 'md', label: FILE_EXT_TO_EXT_LABEL.md },
421
- { value: 'mdx', label: FILE_EXT_TO_EXT_LABEL.mdx },
422
- { value: 'ts', label: FILE_EXT_TO_EXT_LABEL.ts },
423
- { value: 'js', label: FILE_EXT_TO_EXT_LABEL.js },
424
- { value: 'yaml', label: FILE_EXT_TO_EXT_LABEL.yaml },
425
- // TWILIO_CONTENT_JSON not supported in CLI init as its too niche
426
- ],
427
- required: !isUsingGT,
428
- });
429
- const files = {};
430
- for (const fileExtension of fileExtensions) {
431
- const paths = await promptText({
432
- message: `${chalk.cyan(FILE_EXT_TO_EXT_LABEL[fileExtension])}: Enter a space-separated list of glob patterns matching the location of the ${FILE_EXT_TO_EXT_LABEL[fileExtension]} files you would like to translate.\nMake sure to include [locale] in the patterns.\nSee https://generaltranslation.com/docs/cli/reference/config#include for more information.`,
433
- defaultValue: `./**/[locale]/*.${fileExtension}`,
434
- });
435
- files[fileExtension] = {
436
- include: paths.split(' '),
437
- };
438
- }
439
- // Add GT translations if using GT and storing locally
440
- if (isUsingGT && !usingCDN) {
441
- files.gt = {
442
- output: path.join(finalTranslationsDir, `[locale].json`),
443
- };
444
- }
445
- let configFilepath = 'gt.config.json';
446
- if (fs.existsSync('src/gt.config.json')) {
447
- configFilepath = 'src/gt.config.json';
448
- }
449
- // Create gt.config.json
450
- await createOrUpdateConfig(configFilepath, {
451
- defaultLocale,
452
- locales,
453
- files: Object.keys(files).length > 0 ? files : undefined,
454
- publish: isUsingGT && usingCDN,
455
- });
456
- logger.success(`Edit ${chalk.cyan(configFilepath)} to customize your translation setup. Docs: https://generaltranslation.com/docs/cli/reference/config`);
457
- // Install gt if not installed
458
- const isCLIInstalled = packageJson
459
- ? isPackageInstalled('gt', packageJson, true, true)
460
- : true; // if no package.json, we can't install it
461
- if (!isCLIInstalled) {
462
- const packageManager = await getPackageManager();
463
- const spinner = logger.createSpinner();
464
- spinner.start(`Installing gt as a dev dependency with ${packageManager.name}...`);
465
- await installPackage('gt', packageManager, true);
466
- spinner.stop(chalk.green('Installed gt.'));
467
- }
468
- // Set credentials
469
- if (!areCredentialsSet()) {
470
- const loginQuestion = useDefaults
471
- ? true
472
- : await promptConfirm({
473
- message: 'Would you like the wizard to automatically generate API keys and a project ID for you?',
474
- defaultValue: true,
475
- });
476
- if (loginQuestion) {
477
- const settings = await generateSettings({});
478
- const keyType = useDefaults
479
- ? 'all'
480
- : await promptSelect({
481
- message: 'What type of API key would you like to generate?',
482
- options: [
483
- { value: 'development', label: 'Development' },
484
- { value: 'production', label: 'Production' },
485
- { value: 'all', label: 'Both' },
486
- ],
487
- defaultValue: 'all',
488
- });
489
- const credentials = await retrieveCredentials(settings, keyType);
490
- await setCredentials(credentials, settings.framework);
491
- }
492
- }
493
- }
494
- async handleLoginCommand(options) {
495
- const settings = await generateSettings({ config: options.config });
496
- const keyType = options.keyType || 'all';
497
- const credentials = await retrieveCredentials(settings, keyType);
498
- await setCredentials(credentials, settings.framework);
499
- }
500
- }
292
+ }
293
+ const message = !isUsingGT ? "What is the format of your language resource files? Select as many as applicable.\nAdditionally, you can translate any other files you have in your project." : `Do you have any additional files in this project to translate? For example, Markdown files for docs. ${chalk.dim("(To continue without selecting press Enter)")}`;
294
+ const fileExtensions = useDefaults && isUsingGT ? [] : await promptMultiSelect({
295
+ message,
296
+ options: [
297
+ {
298
+ value: "json",
299
+ label: FILE_EXT_TO_EXT_LABEL.json
300
+ },
301
+ {
302
+ value: "md",
303
+ label: FILE_EXT_TO_EXT_LABEL.md
304
+ },
305
+ {
306
+ value: "mdx",
307
+ label: FILE_EXT_TO_EXT_LABEL.mdx
308
+ },
309
+ {
310
+ value: "ts",
311
+ label: FILE_EXT_TO_EXT_LABEL.ts
312
+ },
313
+ {
314
+ value: "js",
315
+ label: FILE_EXT_TO_EXT_LABEL.js
316
+ },
317
+ {
318
+ value: "yaml",
319
+ label: FILE_EXT_TO_EXT_LABEL.yaml
320
+ }
321
+ ],
322
+ required: !isUsingGT
323
+ });
324
+ const files = {};
325
+ for (const fileExtension of fileExtensions) {
326
+ const label = FILE_EXT_TO_EXT_LABEL[fileExtension];
327
+ files[fileExtension] = { include: parseGlobPatterns(await promptGlobPatterns({
328
+ label,
329
+ message: `${chalk.cyan(FILE_EXT_TO_EXT_LABEL[fileExtension])}: Enter a space-separated list of glob patterns matching the location of the ${FILE_EXT_TO_EXT_LABEL[fileExtension]} files you would like to translate.\nMake sure to include [locale] in the patterns.\nSee https://generaltranslation.com/docs/cli/reference/config#include for more information.`,
330
+ defaultValue: `./**/[locale]/*.${fileExtension}`
331
+ })) };
332
+ }
333
+ if (isUsingGT && !usingCDN) files.gt = { output: path.join(finalTranslationsDir, `[locale].json`) };
334
+ let configFilepath = "gt.config.json";
335
+ if (fs.existsSync("src/gt.config.json")) configFilepath = "src/gt.config.json";
336
+ await createOrUpdateConfig(configFilepath, {
337
+ defaultLocale,
338
+ locales,
339
+ files: Object.keys(files).length > 0 ? files : void 0,
340
+ publish: isUsingGT && usingCDN
341
+ });
342
+ logger.success(`Edit ${chalk.cyan(configFilepath)} to customize your translation setup. Docs: https://generaltranslation.com/docs/cli/reference/config`);
343
+ if (!(packageJson ? isPackageInstalled("gt", packageJson, true, true) : true)) {
344
+ const packageManager = await getPackageManager();
345
+ const spinner = logger.createSpinner();
346
+ spinner.start(`Installing gt as a dev dependency with ${packageManager.name}...`);
347
+ await installPackage("gt", packageManager, true);
348
+ spinner.stop(chalk.green("Installed gt."));
349
+ }
350
+ if (!areCredentialsSet()) {
351
+ if (useDefaults ? true : await promptConfirm({
352
+ message: "Would you like the wizard to automatically generate API keys and a project ID for you?",
353
+ defaultValue: true
354
+ })) {
355
+ const settings = await generateSettings({});
356
+ await setCredentials(await retrieveCredentials(settings, useDefaults ? "all" : await promptSelect({
357
+ message: "What type of API key would you like to generate?",
358
+ options: [
359
+ {
360
+ value: "development",
361
+ label: "Development"
362
+ },
363
+ {
364
+ value: "production",
365
+ label: "Production"
366
+ },
367
+ {
368
+ value: "all",
369
+ label: "Both"
370
+ }
371
+ ],
372
+ defaultValue: "all"
373
+ })), settings.framework);
374
+ }
375
+ }
376
+ }
377
+ async handleLoginCommand(options) {
378
+ const settings = await generateSettings({ config: options.config });
379
+ await setCredentials(await retrieveCredentials(settings, options.keyType || "all"), settings.framework);
380
+ }
381
+ };
382
+ //#endregion
383
+ export { BaseCLI };
384
+
385
+ //# sourceMappingURL=base.js.map