gt 2.14.35 → 2.14.37

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 (430) hide show
  1. package/CHANGELOG.md +22 -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.d.ts +1 -1
  256. package/dist/react/jsx/utils/resolveImportPath.js +125 -108
  257. package/dist/react/jsx/utils/resolveImportPath.js.map +1 -0
  258. package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js +18 -24
  259. package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js.map +1 -0
  260. package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js +412 -579
  261. package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js.map +1 -0
  262. package/dist/react/jsx/utils/stringParsing/derivation/index.js +57 -67
  263. package/dist/react/jsx/utils/stringParsing/derivation/index.js.map +1 -0
  264. package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js +26 -36
  265. package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js.map +1 -0
  266. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js +29 -24
  267. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js.map +1 -0
  268. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js +34 -32
  269. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js.map +1 -0
  270. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +80 -117
  271. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js.map +1 -0
  272. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js +24 -19
  273. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js.map +1 -0
  274. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +18 -21
  275. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js.map +1 -0
  276. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +45 -50
  277. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js.map +1 -0
  278. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +54 -59
  279. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js.map +1 -0
  280. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +56 -69
  281. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js.map +1 -0
  282. package/dist/react/jsx/utils/validateStringFunction.js +21 -29
  283. package/dist/react/jsx/utils/validateStringFunction.js.map +1 -0
  284. package/dist/react/jsx/wrapJsx.js +192 -375
  285. package/dist/react/jsx/wrapJsx.js.map +1 -0
  286. package/dist/react/parse/addVitePlugin/index.js +40 -34
  287. package/dist/react/parse/addVitePlugin/index.js.map +1 -0
  288. package/dist/react/parse/addVitePlugin/installCompiler.js +18 -20
  289. package/dist/react/parse/addVitePlugin/installCompiler.js.map +1 -0
  290. package/dist/react/parse/addVitePlugin/updateViteConfig.js +107 -111
  291. package/dist/react/parse/addVitePlugin/updateViteConfig.js.map +1 -0
  292. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +23 -26
  293. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js.map +1 -0
  294. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +29 -43
  295. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js.map +1 -0
  296. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +70 -104
  297. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js.map +1 -0
  298. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +23 -29
  299. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js.map +1 -0
  300. package/dist/react/parse/createDictionaryUpdates.js +121 -185
  301. package/dist/react/parse/createDictionaryUpdates.js.map +1 -0
  302. package/dist/react/parse/createInlineUpdates.js +123 -139
  303. package/dist/react/parse/createInlineUpdates.js.map +1 -0
  304. package/dist/react/parse/wrapContent.js +131 -156
  305. package/dist/react/parse/wrapContent.js.map +1 -0
  306. package/dist/react/utils/flattenDictionary.js +55 -70
  307. package/dist/react/utils/flattenDictionary.js.map +1 -0
  308. package/dist/react/utils/getEntryAndMetadata.js +14 -10
  309. package/dist/react/utils/getEntryAndMetadata.js.map +1 -0
  310. package/dist/react/utils/getVariableName.js +36 -33
  311. package/dist/react/utils/getVariableName.js.map +1 -0
  312. package/dist/setup/detectFramework.js +85 -102
  313. package/dist/setup/detectFramework.js.map +1 -0
  314. package/dist/setup/frameworkUtils.js +17 -28
  315. package/dist/setup/frameworkUtils.js.map +1 -0
  316. package/dist/setup/userInput.js +24 -31
  317. package/dist/setup/userInput.js.map +1 -0
  318. package/dist/setup/wizard.js +141 -143
  319. package/dist/setup/wizard.js.map +1 -0
  320. package/dist/state/mintlifyRefMap.js +12 -9
  321. package/dist/state/mintlifyRefMap.js.map +1 -0
  322. package/dist/state/recentDownloads.js +26 -23
  323. package/dist/state/recentDownloads.js.map +1 -0
  324. package/dist/state/translateWarnings.js +17 -8
  325. package/dist/state/translateWarnings.js.map +1 -0
  326. package/dist/translation/parse.js +77 -98
  327. package/dist/translation/parse.js.map +1 -0
  328. package/dist/translation/stage.js +28 -43
  329. package/dist/translation/stage.js.map +1 -0
  330. package/dist/translation/validate.js +68 -91
  331. package/dist/translation/validate.js.map +1 -0
  332. package/dist/types/libraries.js +93 -91
  333. package/dist/types/libraries.js.map +1 -0
  334. package/dist/types/parsing.js +19 -10
  335. package/dist/types/parsing.js.map +1 -0
  336. package/dist/utils/addExplicitAnchorIds.js +270 -389
  337. package/dist/utils/addExplicitAnchorIds.js.map +1 -0
  338. package/dist/utils/calculateTimeoutMs.js +11 -6
  339. package/dist/utils/calculateTimeoutMs.js.map +1 -0
  340. package/dist/utils/constants.js +15 -12
  341. package/dist/utils/constants.js.map +1 -0
  342. package/dist/utils/credentials.js +67 -114
  343. package/dist/utils/credentials.js.map +1 -0
  344. package/dist/utils/fetch.js +22 -20
  345. package/dist/utils/fetch.js.map +1 -0
  346. package/dist/utils/flattenJsonFiles.js +27 -34
  347. package/dist/utils/flattenJsonFiles.js.map +1 -0
  348. package/dist/utils/gitDiff.js +30 -32
  349. package/dist/utils/gitDiff.js.map +1 -0
  350. package/dist/utils/gt.js +7 -2
  351. package/dist/utils/gt.js.map +1 -0
  352. package/dist/utils/hash.js +14 -9
  353. package/dist/utils/hash.js.map +1 -0
  354. package/dist/utils/headers.js +10 -13
  355. package/dist/utils/headers.js.map +1 -0
  356. package/dist/utils/installPackage.js +70 -75
  357. package/dist/utils/installPackage.js.map +1 -0
  358. package/dist/utils/localizeRelativeAssets.js +114 -157
  359. package/dist/utils/localizeRelativeAssets.js.map +1 -0
  360. package/dist/utils/localizeStaticImports.js +229 -371
  361. package/dist/utils/localizeStaticImports.js.map +1 -0
  362. package/dist/utils/localizeStaticUrls.js +241 -424
  363. package/dist/utils/localizeStaticUrls.js.map +1 -0
  364. package/dist/utils/mintlifyTitleFallback.js +64 -72
  365. package/dist/utils/mintlifyTitleFallback.js.map +1 -0
  366. package/dist/utils/monorepoVersionCheck.js +177 -215
  367. package/dist/utils/monorepoVersionCheck.js.map +1 -0
  368. package/dist/utils/packageInfo.js +17 -16
  369. package/dist/utils/packageInfo.js.map +1 -0
  370. package/dist/utils/packageJson.js +51 -66
  371. package/dist/utils/packageJson.js.map +1 -0
  372. package/dist/utils/packageManager.js +237 -260
  373. package/dist/utils/packageManager.js.map +1 -0
  374. package/dist/utils/parse/needsCJS.js +36 -69
  375. package/dist/utils/parse/needsCJS.js.map +1 -0
  376. package/dist/utils/persistPostprocessHashes.js +30 -32
  377. package/dist/utils/persistPostprocessHashes.js.map +1 -0
  378. package/dist/utils/processAnchorIds.js +32 -54
  379. package/dist/utils/processAnchorIds.js.map +1 -0
  380. package/dist/utils/processOpenApi.js +469 -578
  381. package/dist/utils/processOpenApi.js.map +1 -0
  382. package/dist/utils/resolveMintlifyRefs.js +89 -105
  383. package/dist/utils/resolveMintlifyRefs.js.map +1 -0
  384. package/dist/utils/resolvePublish.js +46 -54
  385. package/dist/utils/resolvePublish.js.map +1 -0
  386. package/dist/utils/sanitizeFileContent.js +20 -27
  387. package/dist/utils/sanitizeFileContent.js.map +1 -0
  388. package/dist/utils/sharedStaticAssets.js +248 -366
  389. package/dist/utils/sharedStaticAssets.js.map +1 -0
  390. package/dist/utils/splitMintlifyLanguageRefs.js +208 -282
  391. package/dist/utils/splitMintlifyLanguageRefs.js.map +1 -0
  392. package/dist/utils/validateMdx.js +26 -23
  393. package/dist/utils/validateMdx.js.map +1 -0
  394. package/dist/utils/wrapPlainUrls.js +58 -70
  395. package/dist/utils/wrapPlainUrls.js.map +1 -0
  396. package/dist/workflows/download.js +92 -126
  397. package/dist/workflows/download.js.map +1 -0
  398. package/dist/workflows/enqueue.js +47 -54
  399. package/dist/workflows/enqueue.js.map +1 -0
  400. package/dist/workflows/publish.js +29 -29
  401. package/dist/workflows/publish.js.map +1 -0
  402. package/dist/workflows/setupProject.js +39 -40
  403. package/dist/workflows/setupProject.js.map +1 -0
  404. package/dist/workflows/stage.js +61 -65
  405. package/dist/workflows/stage.js.map +1 -0
  406. package/dist/workflows/steps/BranchStep.js +118 -163
  407. package/dist/workflows/steps/BranchStep.js.map +1 -0
  408. package/dist/workflows/steps/DownloadStep.js +107 -137
  409. package/dist/workflows/steps/DownloadStep.js.map +1 -0
  410. package/dist/workflows/steps/EnqueueStep.js +32 -32
  411. package/dist/workflows/steps/EnqueueStep.js.map +1 -0
  412. package/dist/workflows/steps/PollJobsStep.js +208 -292
  413. package/dist/workflows/steps/PollJobsStep.js.map +1 -0
  414. package/dist/workflows/steps/PublishStep.js +33 -38
  415. package/dist/workflows/steps/PublishStep.js.map +1 -0
  416. package/dist/workflows/steps/SetupStep.js +71 -72
  417. package/dist/workflows/steps/SetupStep.js.map +1 -0
  418. package/dist/workflows/steps/TagStep.js +39 -44
  419. package/dist/workflows/steps/TagStep.js.map +1 -0
  420. package/dist/workflows/steps/UploadSourcesStep.js +108 -140
  421. package/dist/workflows/steps/UploadSourcesStep.js.map +1 -0
  422. package/dist/workflows/steps/UploadTranslationsStep.js +61 -71
  423. package/dist/workflows/steps/UploadTranslationsStep.js.map +1 -0
  424. package/dist/workflows/steps/UserEditDiffsStep.js +32 -34
  425. package/dist/workflows/steps/UserEditDiffsStep.js.map +1 -0
  426. package/dist/workflows/steps/WorkflowStep.js +6 -2
  427. package/dist/workflows/steps/WorkflowStep.js.map +1 -0
  428. package/dist/workflows/upload.js +45 -46
  429. package/dist/workflows/upload.js.map +1 -0
  430. package/package.json +14 -7
@@ -1,117 +1,80 @@
1
- import { runDownloadWorkflow, } from '../../workflows/download.js';
2
- import { createFileMapping } from '../../formats/files/fileMapping.js';
3
- import copyFile from '../../fs/copyFile.js';
4
- import flattenJsonFiles from '../../utils/flattenJsonFiles.js';
5
- import localizeStaticUrls from '../../utils/localizeStaticUrls.js';
6
- import localizeRelativeAssets from '../../utils/localizeRelativeAssets.js';
7
- import processAnchorIds from '../../utils/processAnchorIds.js';
8
- import processOpenApi from '../../utils/processOpenApi.js';
9
- import localizeStaticImports from '../../utils/localizeStaticImports.js';
10
- import { getDownloadedMeta } from '../../state/recentDownloads.js';
11
- import { persistPostProcessHashes } from '../../utils/persistPostprocessHashes.js';
12
- import { runPublishWorkflow } from '../../workflows/publish.js';
13
- import { SUPPORTED_FILE_EXTENSIONS } from '../../formats/files/supportedFiles.js';
14
- import { hasNonIdentityFileFormatTransformForType } from '../../formats/files/transformFormat.js';
15
- import { getRelative } from '../../fs/findFilepath.js';
16
- // Downloads translations that were completed
17
- export async function handleTranslate(options, settings, fileVersionData, jobData, branchData, publishMap) {
18
- if (fileVersionData) {
19
- const { resolvedPaths, placeholderPaths, transformPaths, transformFormats, } = settings.files;
20
- const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, transformFormats, settings.locales, settings.defaultLocale);
21
- // Check for remaining translations
22
- await runDownloadWorkflow({
23
- fileVersionData: fileVersionData,
24
- jobData: jobData,
25
- branchData: branchData,
26
- locales: settings.locales,
27
- timeoutDuration: options.timeout,
28
- resolveOutputPath: (sourcePath, locale) => fileMapping[locale]?.[sourcePath] ?? null,
29
- options: settings,
30
- forceRetranslation: options.force,
31
- forceDownload: options.forceDownload || options.force, // if force is true should also force download
32
- });
33
- // Publish/unpublish files after translations are downloaded
34
- if (publishMap && branchData?.currentBranch.id) {
35
- const files = Object.entries(fileVersionData).map(([fileId, data]) => ({
36
- fileId,
37
- versionId: data.versionId,
38
- fileName: data.fileName,
39
- }));
40
- await runPublishWorkflow(files, publishMap, branchData.currentBranch.id, settings);
41
- }
42
- }
1
+ import { getRelative } from "../../fs/findFilepath.js";
2
+ import { SUPPORTED_FILE_EXTENSIONS } from "../../formats/files/supportedFiles.js";
3
+ import { hasNonIdentityFileFormatTransformForType } from "../../formats/files/transformFormat.js";
4
+ import { createFileMapping } from "../../formats/files/fileMapping.js";
5
+ import { runPublishWorkflow } from "../../workflows/publish.js";
6
+ import { getDownloadedMeta } from "../../state/recentDownloads.js";
7
+ import { runDownloadWorkflow } from "../../workflows/download.js";
8
+ import copyFile from "../../fs/copyFile.js";
9
+ import flattenJsonFiles from "../../utils/flattenJsonFiles.js";
10
+ import localizeStaticUrls from "../../utils/localizeStaticUrls.js";
11
+ import localizeRelativeAssets from "../../utils/localizeRelativeAssets.js";
12
+ import processAnchorIds from "../../utils/processAnchorIds.js";
13
+ import processOpenApi from "../../utils/processOpenApi.js";
14
+ import localizeStaticImports from "../../utils/localizeStaticImports.js";
15
+ import { persistPostProcessHashes } from "../../utils/persistPostprocessHashes.js";
16
+ //#region src/cli/commands/translate.ts
17
+ async function handleTranslate(options, settings, fileVersionData, jobData, branchData, publishMap) {
18
+ if (fileVersionData) {
19
+ const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } = settings.files;
20
+ const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, transformFormats, settings.locales, settings.defaultLocale);
21
+ await runDownloadWorkflow({
22
+ fileVersionData,
23
+ jobData,
24
+ branchData,
25
+ locales: settings.locales,
26
+ timeoutDuration: options.timeout,
27
+ resolveOutputPath: (sourcePath, locale) => fileMapping[locale]?.[sourcePath] ?? null,
28
+ options: settings,
29
+ forceRetranslation: options.force,
30
+ forceDownload: options.forceDownload || options.force
31
+ });
32
+ if (publishMap && branchData?.currentBranch.id) await runPublishWorkflow(Object.entries(fileVersionData).map(([fileId, data]) => ({
33
+ fileId,
34
+ versionId: data.versionId,
35
+ fileName: data.fileName
36
+ })), publishMap, branchData.currentBranch.id, settings);
37
+ }
43
38
  }
44
- export async function postProcessTranslations(settings, includeFiles) {
45
- const postProcessIncludes = filterPostProcessIncludesForFormatTransforms(settings, includeFiles);
46
- if (includeFiles && postProcessIncludes?.size === 0)
47
- return;
48
- // Mintlify OpenAPI localization (spec routing + validation)
49
- await processOpenApi(settings, postProcessIncludes);
50
- // Localize static urls (/docs -> /[locale]/docs) and preserve anchor IDs for non-default locales
51
- // Default locale is processed earlier in the flow in base.ts
52
- if (settings.options?.experimentalLocalizeStaticUrls) {
53
- const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
54
- if (nonDefaultLocales.length > 0) {
55
- await localizeStaticUrls(settings, nonDefaultLocales, postProcessIncludes);
56
- }
57
- }
58
- // Rewrite relative asset URLs in translated md/mdx files
59
- if (settings.options?.experimentalLocalizeRelativeAssets) {
60
- const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
61
- if (nonDefaultLocales.length > 0) {
62
- await localizeRelativeAssets(settings, nonDefaultLocales, postProcessIncludes);
63
- }
64
- }
65
- const shouldProcessAnchorIds = settings.options?.experimentalLocalizeStaticUrls ||
66
- settings.options?.experimentalAddHeaderAnchorIds;
67
- // Add explicit anchor IDs to translated MDX/MD files to preserve navigation
68
- // Uses inline {#id} format by default, or div wrapping if experimentalAddHeaderAnchorIds is 'mintlify'
69
- if (shouldProcessAnchorIds) {
70
- await processAnchorIds(settings, postProcessIncludes);
71
- }
72
- // Localize static imports (import Snippet from /snippets/file.mdx -> import Snippet from /snippets/[locale]/file.mdx)
73
- if (settings.options?.experimentalLocalizeStaticImports) {
74
- await localizeStaticImports(settings, postProcessIncludes);
75
- }
76
- // Flatten json files into a single file
77
- if (settings.options?.experimentalFlattenJsonFiles) {
78
- await flattenJsonFiles(settings, postProcessIncludes);
79
- }
80
- // Copy files to the target locale
81
- if (settings.options?.copyFiles) {
82
- await copyFile(settings);
83
- }
84
- // Record postprocessed content hashes for newly downloaded files
85
- persistPostProcessHashes(settings, postProcessIncludes, getDownloadedMeta());
39
+ async function postProcessTranslations(settings, includeFiles) {
40
+ const postProcessIncludes = filterPostProcessIncludesForFormatTransforms(settings, includeFiles);
41
+ if (includeFiles && postProcessIncludes?.size === 0) return;
42
+ await processOpenApi(settings, postProcessIncludes);
43
+ if (settings.options?.experimentalLocalizeStaticUrls) {
44
+ const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
45
+ if (nonDefaultLocales.length > 0) await localizeStaticUrls(settings, nonDefaultLocales, postProcessIncludes);
46
+ }
47
+ if (settings.options?.experimentalLocalizeRelativeAssets) {
48
+ const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
49
+ if (nonDefaultLocales.length > 0) await localizeRelativeAssets(settings, nonDefaultLocales, postProcessIncludes);
50
+ }
51
+ if (settings.options?.experimentalLocalizeStaticUrls || settings.options?.experimentalAddHeaderAnchorIds) await processAnchorIds(settings, postProcessIncludes);
52
+ if (settings.options?.experimentalLocalizeStaticImports) await localizeStaticImports(settings, postProcessIncludes);
53
+ if (settings.options?.experimentalFlattenJsonFiles) await flattenJsonFiles(settings, postProcessIncludes);
54
+ if (settings.options?.copyFiles) await copyFile(settings);
55
+ persistPostProcessHashes(settings, postProcessIncludes, getDownloadedMeta());
86
56
  }
87
57
  /**
88
- * Exclude only outputs whose source file was translated into a different format.
89
- * @param settings - The settings for the project
90
- * @param includeFiles - The files to include in the post-processing
91
- * @returns The files to exclude in the post-processing
92
- */
58
+ * Exclude only outputs whose source file was translated into a different format.
59
+ * @param settings - The settings for the project
60
+ * @param includeFiles - The files to include in the post-processing
61
+ * @returns The files to exclude in the post-processing
62
+ */
93
63
  function filterPostProcessIncludesForFormatTransforms(settings, includeFiles) {
94
- if (!includeFiles)
95
- return includeFiles;
96
- const transformedSourcePaths = new Set();
97
- for (const fileType of SUPPORTED_FILE_EXTENSIONS) {
98
- if (!hasNonIdentityFileFormatTransformForType(settings, fileType))
99
- continue;
100
- for (const sourcePath of settings.files.resolvedPaths[fileType] || []) {
101
- transformedSourcePaths.add(getRelative(sourcePath));
102
- }
103
- }
104
- if (transformedSourcePaths.size === 0)
105
- return includeFiles;
106
- const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } = settings.files;
107
- const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, transformFormats, settings.locales, settings.defaultLocale);
108
- const transformedOutputPaths = new Set();
109
- for (const localeMapping of Object.values(fileMapping)) {
110
- for (const [sourcePath, outputPath] of Object.entries(localeMapping)) {
111
- if (transformedSourcePaths.has(sourcePath)) {
112
- transformedOutputPaths.add(outputPath);
113
- }
114
- }
115
- }
116
- return new Set([...includeFiles].filter((filePath) => !transformedOutputPaths.has(filePath)));
64
+ if (!includeFiles) return includeFiles;
65
+ const transformedSourcePaths = /* @__PURE__ */ new Set();
66
+ for (const fileType of SUPPORTED_FILE_EXTENSIONS) {
67
+ if (!hasNonIdentityFileFormatTransformForType(settings, fileType)) continue;
68
+ for (const sourcePath of settings.files.resolvedPaths[fileType] || []) transformedSourcePaths.add(getRelative(sourcePath));
69
+ }
70
+ if (transformedSourcePaths.size === 0) return includeFiles;
71
+ const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } = settings.files;
72
+ const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, transformFormats, settings.locales, settings.defaultLocale);
73
+ const transformedOutputPaths = /* @__PURE__ */ new Set();
74
+ for (const localeMapping of Object.values(fileMapping)) for (const [sourcePath, outputPath] of Object.entries(localeMapping)) if (transformedSourcePaths.has(sourcePath)) transformedOutputPaths.add(outputPath);
75
+ return new Set([...includeFiles].filter((filePath) => !transformedOutputPaths.has(filePath)));
117
76
  }
77
+ //#endregion
78
+ export { handleTranslate, postProcessTranslations };
79
+
80
+ //# sourceMappingURL=translate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.js","names":[],"sources":["../../../src/cli/commands/translate.ts"],"sourcesContent":["import { EnqueueFilesResult } from 'generaltranslation/types';\nimport { TranslateFlags } from '../../types/index.js';\nimport { Settings } from '../../types/index.js';\nimport {\n FileTranslationData,\n runDownloadWorkflow,\n} from '../../workflows/download.js';\nimport { createFileMapping } from '../../formats/files/fileMapping.js';\nimport copyFile from '../../fs/copyFile.js';\nimport flattenJsonFiles from '../../utils/flattenJsonFiles.js';\nimport localizeStaticUrls from '../../utils/localizeStaticUrls.js';\nimport localizeRelativeAssets from '../../utils/localizeRelativeAssets.js';\nimport processAnchorIds from '../../utils/processAnchorIds.js';\nimport processOpenApi from '../../utils/processOpenApi.js';\nimport localizeStaticImports from '../../utils/localizeStaticImports.js';\nimport { BranchData } from '../../types/branch.js';\nimport { getDownloadedMeta } from '../../state/recentDownloads.js';\nimport { persistPostProcessHashes } from '../../utils/persistPostprocessHashes.js';\nimport { runPublishWorkflow } from '../../workflows/publish.js';\nimport { SUPPORTED_FILE_EXTENSIONS } from '../../formats/files/supportedFiles.js';\nimport { hasNonIdentityFileFormatTransformForType } from '../../formats/files/transformFormat.js';\nimport { getRelative } from '../../fs/findFilepath.js';\n\n// Downloads translations that were completed\nexport async function handleTranslate(\n options: TranslateFlags,\n settings: Settings,\n fileVersionData: FileTranslationData | undefined,\n jobData: EnqueueFilesResult | undefined,\n branchData: BranchData | undefined,\n publishMap?: Map<string, boolean>\n) {\n if (fileVersionData) {\n const {\n resolvedPaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n } = settings.files;\n\n const fileMapping = createFileMapping(\n resolvedPaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n settings.locales,\n settings.defaultLocale\n );\n // Check for remaining translations\n await runDownloadWorkflow({\n fileVersionData: fileVersionData,\n jobData: jobData,\n branchData: branchData,\n locales: settings.locales,\n timeoutDuration: options.timeout,\n resolveOutputPath: (sourcePath, locale) =>\n fileMapping[locale]?.[sourcePath] ?? null,\n options: settings,\n forceRetranslation: options.force,\n forceDownload: options.forceDownload || options.force, // if force is true should also force download\n });\n\n // Publish/unpublish files after translations are downloaded\n if (publishMap && branchData?.currentBranch.id) {\n const files = Object.entries(fileVersionData).map(([fileId, data]) => ({\n fileId,\n versionId: data.versionId,\n fileName: data.fileName,\n }));\n await runPublishWorkflow(\n files,\n publishMap,\n branchData.currentBranch.id,\n settings\n );\n }\n }\n}\n\nexport async function postProcessTranslations(\n settings: Settings,\n includeFiles?: Set<string>\n) {\n const postProcessIncludes = filterPostProcessIncludesForFormatTransforms(\n settings,\n includeFiles\n );\n if (includeFiles && postProcessIncludes?.size === 0) return;\n\n // Mintlify OpenAPI localization (spec routing + validation)\n await processOpenApi(settings, postProcessIncludes);\n\n // Localize static urls (/docs -> /[locale]/docs) and preserve anchor IDs for non-default locales\n // Default locale is processed earlier in the flow in base.ts\n if (settings.options?.experimentalLocalizeStaticUrls) {\n const nonDefaultLocales = settings.locales.filter(\n (locale) => locale !== settings.defaultLocale\n );\n if (nonDefaultLocales.length > 0) {\n await localizeStaticUrls(\n settings,\n nonDefaultLocales,\n postProcessIncludes\n );\n }\n }\n\n // Rewrite relative asset URLs in translated md/mdx files\n if (settings.options?.experimentalLocalizeRelativeAssets) {\n const nonDefaultLocales = settings.locales.filter(\n (locale) => locale !== settings.defaultLocale\n );\n if (nonDefaultLocales.length > 0) {\n await localizeRelativeAssets(\n settings,\n nonDefaultLocales,\n postProcessIncludes\n );\n }\n }\n\n const shouldProcessAnchorIds =\n settings.options?.experimentalLocalizeStaticUrls ||\n settings.options?.experimentalAddHeaderAnchorIds;\n\n // Add explicit anchor IDs to translated MDX/MD files to preserve navigation\n // Uses inline {#id} format by default, or div wrapping if experimentalAddHeaderAnchorIds is 'mintlify'\n if (shouldProcessAnchorIds) {\n await processAnchorIds(settings, postProcessIncludes);\n }\n\n // Localize static imports (import Snippet from /snippets/file.mdx -> import Snippet from /snippets/[locale]/file.mdx)\n if (settings.options?.experimentalLocalizeStaticImports) {\n await localizeStaticImports(settings, postProcessIncludes);\n }\n\n // Flatten json files into a single file\n if (settings.options?.experimentalFlattenJsonFiles) {\n await flattenJsonFiles(settings, postProcessIncludes);\n }\n\n // Copy files to the target locale\n if (settings.options?.copyFiles) {\n await copyFile(settings);\n }\n\n // Record postprocessed content hashes for newly downloaded files\n persistPostProcessHashes(settings, postProcessIncludes, getDownloadedMeta());\n}\n\n/**\n * Exclude only outputs whose source file was translated into a different format.\n * @param settings - The settings for the project\n * @param includeFiles - The files to include in the post-processing\n * @returns The files to exclude in the post-processing\n */\nfunction filterPostProcessIncludesForFormatTransforms(\n settings: Settings,\n includeFiles?: Set<string>\n): Set<string> | undefined {\n if (!includeFiles) return includeFiles;\n\n const transformedSourcePaths = new Set<string>();\n for (const fileType of SUPPORTED_FILE_EXTENSIONS) {\n if (!hasNonIdentityFileFormatTransformForType(settings, fileType)) continue;\n\n for (const sourcePath of settings.files.resolvedPaths[fileType] || []) {\n transformedSourcePaths.add(getRelative(sourcePath));\n }\n }\n if (transformedSourcePaths.size === 0) return includeFiles;\n\n const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } =\n settings.files;\n const fileMapping = createFileMapping(\n resolvedPaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n settings.locales,\n settings.defaultLocale\n );\n\n const transformedOutputPaths = new Set<string>();\n for (const localeMapping of Object.values(fileMapping)) {\n for (const [sourcePath, outputPath] of Object.entries(localeMapping)) {\n if (transformedSourcePaths.has(sourcePath)) {\n transformedOutputPaths.add(outputPath);\n }\n }\n }\n\n return new Set(\n [...includeFiles].filter(\n (filePath) => !transformedOutputPaths.has(filePath)\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,eAAsB,gBACpB,SACA,UACA,iBACA,SACA,YACA,YACA;AACA,KAAI,iBAAiB;EACnB,MAAM,EACJ,eACA,kBACA,gBACA,qBACE,SAAS;EAEb,MAAM,cAAc,kBAClB,eACA,kBACA,gBACA,kBACA,SAAS,SACT,SAAS,cACV;AAED,QAAM,oBAAoB;GACP;GACR;GACG;GACZ,SAAS,SAAS;GAClB,iBAAiB,QAAQ;GACzB,oBAAoB,YAAY,WAC9B,YAAY,UAAU,eAAe;GACvC,SAAS;GACT,oBAAoB,QAAQ;GAC5B,eAAe,QAAQ,iBAAiB,QAAQ;GACjD,CAAC;AAGF,MAAI,cAAc,YAAY,cAAc,GAM1C,OAAM,mBALQ,OAAO,QAAQ,gBAAgB,CAAC,KAAK,CAAC,QAAQ,WAAW;GACrE;GACA,WAAW,KAAK;GAChB,UAAU,KAAK;GAChB,EAEM,EACL,YACA,WAAW,cAAc,IACzB,SACD;;;AAKP,eAAsB,wBACpB,UACA,cACA;CACA,MAAM,sBAAsB,6CAC1B,UACA,aACD;AACD,KAAI,gBAAgB,qBAAqB,SAAS,EAAG;AAGrD,OAAM,eAAe,UAAU,oBAAoB;AAInD,KAAI,SAAS,SAAS,gCAAgC;EACpD,MAAM,oBAAoB,SAAS,QAAQ,QACxC,WAAW,WAAW,SAAS,cACjC;AACD,MAAI,kBAAkB,SAAS,EAC7B,OAAM,mBACJ,UACA,mBACA,oBACD;;AAKL,KAAI,SAAS,SAAS,oCAAoC;EACxD,MAAM,oBAAoB,SAAS,QAAQ,QACxC,WAAW,WAAW,SAAS,cACjC;AACD,MAAI,kBAAkB,SAAS,EAC7B,OAAM,uBACJ,UACA,mBACA,oBACD;;AAUL,KALE,SAAS,SAAS,kCAClB,SAAS,SAAS,+BAKlB,OAAM,iBAAiB,UAAU,oBAAoB;AAIvD,KAAI,SAAS,SAAS,kCACpB,OAAM,sBAAsB,UAAU,oBAAoB;AAI5D,KAAI,SAAS,SAAS,6BACpB,OAAM,iBAAiB,UAAU,oBAAoB;AAIvD,KAAI,SAAS,SAAS,UACpB,OAAM,SAAS,SAAS;AAI1B,0BAAyB,UAAU,qBAAqB,mBAAmB,CAAC;;;;;;;;AAS9E,SAAS,6CACP,UACA,cACyB;AACzB,KAAI,CAAC,aAAc,QAAO;CAE1B,MAAM,yCAAyB,IAAI,KAAa;AAChD,MAAK,MAAM,YAAY,2BAA2B;AAChD,MAAI,CAAC,yCAAyC,UAAU,SAAS,CAAE;AAEnE,OAAK,MAAM,cAAc,SAAS,MAAM,cAAc,aAAa,EAAE,CACnE,wBAAuB,IAAI,YAAY,WAAW,CAAC;;AAGvD,KAAI,uBAAuB,SAAS,EAAG,QAAO;CAE9C,MAAM,EAAE,eAAe,kBAAkB,gBAAgB,qBACvD,SAAS;CACX,MAAM,cAAc,kBAClB,eACA,kBACA,gBACA,kBACA,SAAS,SACT,SAAS,cACV;CAED,MAAM,yCAAyB,IAAI,KAAa;AAChD,MAAK,MAAM,iBAAiB,OAAO,OAAO,YAAY,CACpD,MAAK,MAAM,CAAC,YAAY,eAAe,OAAO,QAAQ,cAAc,CAClE,KAAI,uBAAuB,IAAI,WAAW,CACxC,wBAAuB,IAAI,WAAW;AAK5C,QAAO,IAAI,IACT,CAAC,GAAG,aAAa,CAAC,QACf,aAAa,CAAC,uBAAuB,IAAI,SAAS,CACpD,CACF"}
@@ -1,215 +1,187 @@
1
- import { noSupportedFormatError, noDefaultLocaleError, } from '../../console/index.js';
2
- import { exitSync, logErrorAndExit } from '../../console/logging.js';
3
- import { logger } from '../../console/logger.js';
4
- import { getRelative, readFile } from '../../fs/findFilepath.js';
5
- import { SUPPORTED_FILE_EXTENSIONS } from '../../formats/files/supportedFiles.js';
6
- import sanitizeFileContent from '../../utils/sanitizeFileContent.js';
7
- import { parseJson } from '../../formats/json/parseJson.js';
8
- import { extractJson } from '../../formats/json/extractJson.js';
9
- import { validateJsonSchema } from '../../formats/json/utils.js';
10
- import { resolveMintlifyRefs, shouldResolveRefs, } from '../../utils/resolveMintlifyRefs.js';
11
- import { runUploadFilesWorkflow } from '../../workflows/upload.js';
12
- import { existsSync, readFileSync } from 'node:fs';
13
- import { createFileMapping } from '../../formats/files/fileMapping.js';
14
- import parseYaml from '../../formats/yaml/parseYaml.js';
15
- import { hashStringSync } from '../../utils/hash.js';
16
- import { hasValidCredentials } from './utils/validation.js';
17
- import { buildPublishMap } from '../../utils/resolvePublish.js';
18
- import { runPublishWorkflow } from '../../workflows/publish.js';
19
- import { getTransformFormatProperty } from '../../formats/files/transformFormat.js';
20
- const SUPPORTED_DATA_FORMATS = ['JSX', 'ICU', 'I18NEXT'];
1
+ import { logger } from "../../console/logger.js";
2
+ import { hashStringSync } from "../../utils/hash.js";
3
+ import { exitSync, logErrorAndExit } from "../../console/logging.js";
4
+ import { getRelative, readFile } from "../../fs/findFilepath.js";
5
+ import { noDefaultLocaleError, noSupportedFormatError } from "../../console/index.js";
6
+ import { SUPPORTED_FILE_EXTENSIONS } from "../../formats/files/supportedFiles.js";
7
+ import { getTransformFormatProperty } from "../../formats/files/transformFormat.js";
8
+ import sanitizeFileContent from "../../utils/sanitizeFileContent.js";
9
+ import { validateJsonSchema } from "../../formats/json/utils.js";
10
+ import { parseJson } from "../../formats/json/parseJson.js";
11
+ import { extractJson } from "../../formats/json/extractJson.js";
12
+ import { resolveMintlifyRefs, shouldResolveRefs } from "../../utils/resolveMintlifyRefs.js";
13
+ import { runUploadFilesWorkflow } from "../../workflows/upload.js";
14
+ import { createFileMapping } from "../../formats/files/fileMapping.js";
15
+ import parseYaml from "../../formats/yaml/parseYaml.js";
16
+ import { hasValidCredentials } from "./utils/validation.js";
17
+ import { buildPublishMap } from "../../utils/resolvePublish.js";
18
+ import { runPublishWorkflow } from "../../workflows/publish.js";
19
+ import { existsSync, readFileSync } from "node:fs";
20
+ //#region src/cli/commands/upload.ts
21
+ const SUPPORTED_DATA_FORMATS = [
22
+ "JSX",
23
+ "ICU",
24
+ "I18NEXT"
25
+ ];
21
26
  /**
22
- * Sends multiple files to the API for translation
23
- * @param filePaths - Resolved file paths for different file types
24
- * @param placeholderPaths - Placeholder paths for translated files
25
- * @param transformPaths - Transform paths for file naming
26
- * @param dataFormat - Format of the data within the files
27
- * @param settings - Translation options including API settings
28
- * @returns Promise that resolves when translation is complete
29
- */
30
- export async function upload(filePaths, placeholderPaths, transformPaths, dataFormat = 'JSX', settings) {
31
- // Collect all files to translate
32
- const allFiles = [];
33
- const additionalOptions = settings.options || {};
34
- const compositeJsonFiles = new Map();
35
- // Process JSON files
36
- if (filePaths.json) {
37
- if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) {
38
- logErrorAndExit(noSupportedFormatError);
39
- }
40
- const jsonFiles = filePaths.json.map((filePath) => {
41
- const content = readFile(filePath);
42
- // Resolve $ref before parsing if configured
43
- let contentForParsing = content;
44
- if (shouldResolveRefs(filePath, additionalOptions)) {
45
- try {
46
- const json = JSON.parse(content);
47
- const { resolved } = resolveMintlifyRefs(json, filePath);
48
- contentForParsing = JSON.stringify(resolved, null, 2);
49
- }
50
- catch {
51
- // JSON parse errors are handled below by parseJson
52
- }
53
- }
54
- const parsedJson = parseJson(contentForParsing, filePath, additionalOptions, settings.defaultLocale);
55
- const relativePath = getRelative(filePath);
56
- const jsonSchema = validateJsonSchema(additionalOptions, filePath);
57
- if (jsonSchema?.composite) {
58
- compositeJsonFiles.set(relativePath, { filePath, content });
59
- }
60
- return {
61
- content: parsedJson,
62
- fileName: relativePath,
63
- fileFormat: 'JSON',
64
- ...getTransformFormatProperty(settings, 'json'),
65
- dataFormat,
66
- locale: settings.defaultLocale,
67
- fileId: hashStringSync(relativePath),
68
- versionId: hashStringSync(parsedJson),
69
- };
70
- });
71
- allFiles.push(...jsonFiles);
72
- }
73
- // Process YAML files
74
- if (filePaths.yaml) {
75
- if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) {
76
- logErrorAndExit(noSupportedFormatError);
77
- }
78
- const yamlFiles = filePaths.yaml.map((filePath) => {
79
- const content = readFile(filePath);
80
- const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, additionalOptions);
81
- const relativePath = getRelative(filePath);
82
- return {
83
- content: parsedYaml,
84
- fileName: relativePath,
85
- fileFormat,
86
- ...getTransformFormatProperty(settings, 'yaml'),
87
- dataFormat,
88
- locale: settings.defaultLocale,
89
- fileId: hashStringSync(relativePath),
90
- versionId: hashStringSync(parsedYaml),
91
- };
92
- });
93
- allFiles.push(...yamlFiles);
94
- }
95
- // Process Twilio Content JSON files
96
- if (filePaths.twilioContentJson) {
97
- const twilioContentJsonFiles = filePaths.twilioContentJson.map((filePath) => {
98
- const content = readFile(filePath);
99
- const parsedJson = parseJson(content, filePath, additionalOptions, settings.defaultLocale);
100
- const relativePath = getRelative(filePath);
101
- return {
102
- content: parsedJson,
103
- fileName: relativePath,
104
- fileFormat: 'TWILIO_CONTENT_JSON',
105
- ...getTransformFormatProperty(settings, 'twilioContentJson'),
106
- dataFormat: 'STRING',
107
- locale: settings.defaultLocale,
108
- fileId: hashStringSync(relativePath),
109
- versionId: hashStringSync(parsedJson),
110
- };
111
- });
112
- allFiles.push(...twilioContentJsonFiles);
113
- }
114
- for (const fileType of SUPPORTED_FILE_EXTENSIONS) {
115
- if (fileType === 'json' ||
116
- fileType === 'yaml' ||
117
- fileType === 'twilioContentJson')
118
- continue;
119
- if (filePaths[fileType]) {
120
- const files = filePaths[fileType].map((filePath) => {
121
- const content = readFile(filePath);
122
- const sanitizedContent = sanitizeFileContent(content);
123
- const relativePath = getRelative(filePath);
124
- return {
125
- content: sanitizedContent,
126
- fileName: relativePath,
127
- fileFormat: fileType.toUpperCase(),
128
- ...getTransformFormatProperty(settings, fileType),
129
- dataFormat,
130
- locale: settings.defaultLocale,
131
- fileId: hashStringSync(relativePath),
132
- versionId: hashStringSync(sanitizedContent),
133
- };
134
- });
135
- allFiles.push(...files);
136
- }
137
- }
138
- if (allFiles.length === 0) {
139
- logger.error('No files to upload were found. Check your configuration and try again.');
140
- return;
141
- }
142
- if (!settings.defaultLocale) {
143
- return logErrorAndExit(noDefaultLocaleError);
144
- }
145
- if (!hasValidCredentials(settings))
146
- return exitSync(1);
147
- const locales = settings.locales || [];
148
- // Create file mapping for all file types
149
- const fileMapping = createFileMapping(filePaths, placeholderPaths, transformPaths, settings.files?.transformFormats || {}, locales, settings.defaultLocale);
150
- // construct object
151
- const uploadData = allFiles.map((file) => {
152
- const sourceFile = {
153
- content: file.content,
154
- fileName: file.fileName,
155
- fileFormat: file.fileFormat,
156
- transformFormat: file.transformFormat,
157
- dataFormat: file.dataFormat,
158
- locale: file.locale,
159
- fileId: file.fileId,
160
- versionId: file.versionId,
161
- };
162
- const translations = [];
163
- const compositeInfo = compositeJsonFiles.get(file.fileName);
164
- for (const locale of locales) {
165
- if (compositeInfo) {
166
- // Composite JSON: extract translations from the same source file
167
- const extracted = extractJson(compositeInfo.content, compositeInfo.filePath, additionalOptions, locale, settings.defaultLocale);
168
- if (extracted) {
169
- translations.push({
170
- content: extracted,
171
- fileName: file.fileName,
172
- fileFormat: file.transformFormat ?? file.fileFormat,
173
- dataFormat: file.dataFormat,
174
- locale,
175
- fileId: file.fileId,
176
- versionId: file.versionId,
177
- });
178
- }
179
- }
180
- else {
181
- // Non-composite: look for separate translation files
182
- const translatedFileName = fileMapping[locale]?.[file.fileName];
183
- if (translatedFileName && existsSync(translatedFileName)) {
184
- const translatedContent = readFileSync(translatedFileName, 'utf8');
185
- translations.push({
186
- content: translatedContent,
187
- fileName: translatedFileName,
188
- fileFormat: file.transformFormat ?? file.fileFormat,
189
- dataFormat: file.dataFormat,
190
- locale,
191
- fileId: file.fileId,
192
- versionId: file.versionId,
193
- });
194
- }
195
- }
196
- }
197
- return {
198
- source: sourceFile,
199
- translations,
200
- };
201
- });
202
- try {
203
- // Send all files in a single API call
204
- const { branchData } = await runUploadFilesWorkflow({
205
- files: uploadData,
206
- options: settings,
207
- });
208
- // Publish files to CDN if publish config exists
209
- const publishMap = buildPublishMap(filePaths, settings);
210
- await runPublishWorkflow(allFiles, publishMap, branchData.currentBranch.id, settings);
211
- }
212
- catch (error) {
213
- logErrorAndExit(`Error uploading files: ${error}`);
214
- }
27
+ * Sends multiple files to the API for translation
28
+ * @param filePaths - Resolved file paths for different file types
29
+ * @param placeholderPaths - Placeholder paths for translated files
30
+ * @param transformPaths - Transform paths for file naming
31
+ * @param dataFormat - Format of the data within the files
32
+ * @param settings - Translation options including API settings
33
+ * @returns Promise that resolves when translation is complete
34
+ */
35
+ async function upload(filePaths, placeholderPaths, transformPaths, dataFormat = "JSX", settings) {
36
+ const allFiles = [];
37
+ const additionalOptions = settings.options || {};
38
+ const compositeJsonFiles = /* @__PURE__ */ new Map();
39
+ if (filePaths.json) {
40
+ if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) logErrorAndExit(noSupportedFormatError);
41
+ const jsonFiles = filePaths.json.map((filePath) => {
42
+ const content = readFile(filePath);
43
+ let contentForParsing = content;
44
+ if (shouldResolveRefs(filePath, additionalOptions)) try {
45
+ const { resolved } = resolveMintlifyRefs(JSON.parse(content), filePath);
46
+ contentForParsing = JSON.stringify(resolved, null, 2);
47
+ } catch {}
48
+ const parsedJson = parseJson(contentForParsing, filePath, additionalOptions, settings.defaultLocale);
49
+ const relativePath = getRelative(filePath);
50
+ if (validateJsonSchema(additionalOptions, filePath)?.composite) compositeJsonFiles.set(relativePath, {
51
+ filePath,
52
+ content
53
+ });
54
+ return {
55
+ content: parsedJson,
56
+ fileName: relativePath,
57
+ fileFormat: "JSON",
58
+ ...getTransformFormatProperty(settings, "json"),
59
+ dataFormat,
60
+ locale: settings.defaultLocale,
61
+ fileId: hashStringSync(relativePath),
62
+ versionId: hashStringSync(parsedJson)
63
+ };
64
+ });
65
+ allFiles.push(...jsonFiles);
66
+ }
67
+ if (filePaths.yaml) {
68
+ if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) logErrorAndExit(noSupportedFormatError);
69
+ const yamlFiles = filePaths.yaml.map((filePath) => {
70
+ const { content: parsedYaml, fileFormat } = parseYaml(readFile(filePath), filePath, additionalOptions);
71
+ const relativePath = getRelative(filePath);
72
+ return {
73
+ content: parsedYaml,
74
+ fileName: relativePath,
75
+ fileFormat,
76
+ ...getTransformFormatProperty(settings, "yaml"),
77
+ dataFormat,
78
+ locale: settings.defaultLocale,
79
+ fileId: hashStringSync(relativePath),
80
+ versionId: hashStringSync(parsedYaml)
81
+ };
82
+ });
83
+ allFiles.push(...yamlFiles);
84
+ }
85
+ if (filePaths.twilioContentJson) {
86
+ const twilioContentJsonFiles = filePaths.twilioContentJson.map((filePath) => {
87
+ const parsedJson = parseJson(readFile(filePath), filePath, additionalOptions, settings.defaultLocale);
88
+ const relativePath = getRelative(filePath);
89
+ return {
90
+ content: parsedJson,
91
+ fileName: relativePath,
92
+ fileFormat: "TWILIO_CONTENT_JSON",
93
+ ...getTransformFormatProperty(settings, "twilioContentJson"),
94
+ dataFormat: "STRING",
95
+ locale: settings.defaultLocale,
96
+ fileId: hashStringSync(relativePath),
97
+ versionId: hashStringSync(parsedJson)
98
+ };
99
+ });
100
+ allFiles.push(...twilioContentJsonFiles);
101
+ }
102
+ for (const fileType of SUPPORTED_FILE_EXTENSIONS) {
103
+ if (fileType === "json" || fileType === "yaml" || fileType === "twilioContentJson") continue;
104
+ if (filePaths[fileType]) {
105
+ const files = filePaths[fileType].map((filePath) => {
106
+ const sanitizedContent = sanitizeFileContent(readFile(filePath));
107
+ const relativePath = getRelative(filePath);
108
+ return {
109
+ content: sanitizedContent,
110
+ fileName: relativePath,
111
+ fileFormat: fileType.toUpperCase(),
112
+ ...getTransformFormatProperty(settings, fileType),
113
+ dataFormat,
114
+ locale: settings.defaultLocale,
115
+ fileId: hashStringSync(relativePath),
116
+ versionId: hashStringSync(sanitizedContent)
117
+ };
118
+ });
119
+ allFiles.push(...files);
120
+ }
121
+ }
122
+ if (allFiles.length === 0) {
123
+ logger.error("No files to upload were found. Check your configuration and try again.");
124
+ return;
125
+ }
126
+ if (!settings.defaultLocale) return logErrorAndExit(noDefaultLocaleError);
127
+ if (!hasValidCredentials(settings)) return exitSync(1);
128
+ const locales = settings.locales || [];
129
+ const fileMapping = createFileMapping(filePaths, placeholderPaths, transformPaths, settings.files?.transformFormats || {}, locales, settings.defaultLocale);
130
+ const uploadData = allFiles.map((file) => {
131
+ const sourceFile = {
132
+ content: file.content,
133
+ fileName: file.fileName,
134
+ fileFormat: file.fileFormat,
135
+ transformFormat: file.transformFormat,
136
+ dataFormat: file.dataFormat,
137
+ locale: file.locale,
138
+ fileId: file.fileId,
139
+ versionId: file.versionId
140
+ };
141
+ const translations = [];
142
+ const compositeInfo = compositeJsonFiles.get(file.fileName);
143
+ for (const locale of locales) if (compositeInfo) {
144
+ const extracted = extractJson(compositeInfo.content, compositeInfo.filePath, additionalOptions, locale, settings.defaultLocale);
145
+ if (extracted) translations.push({
146
+ content: extracted,
147
+ fileName: file.fileName,
148
+ fileFormat: file.transformFormat ?? file.fileFormat,
149
+ dataFormat: file.dataFormat,
150
+ locale,
151
+ fileId: file.fileId,
152
+ versionId: file.versionId
153
+ });
154
+ } else {
155
+ const translatedFileName = fileMapping[locale]?.[file.fileName];
156
+ if (translatedFileName && existsSync(translatedFileName)) {
157
+ const translatedContent = readFileSync(translatedFileName, "utf8");
158
+ translations.push({
159
+ content: translatedContent,
160
+ fileName: translatedFileName,
161
+ fileFormat: file.transformFormat ?? file.fileFormat,
162
+ dataFormat: file.dataFormat,
163
+ locale,
164
+ fileId: file.fileId,
165
+ versionId: file.versionId
166
+ });
167
+ }
168
+ }
169
+ return {
170
+ source: sourceFile,
171
+ translations
172
+ };
173
+ });
174
+ try {
175
+ const { branchData } = await runUploadFilesWorkflow({
176
+ files: uploadData,
177
+ options: settings
178
+ });
179
+ await runPublishWorkflow(allFiles, buildPublishMap(filePaths, settings), branchData.currentBranch.id, settings);
180
+ } catch (error) {
181
+ logErrorAndExit(`Error uploading files: ${error}`);
182
+ }
215
183
  }
184
+ //#endregion
185
+ export { upload };
186
+
187
+ //# sourceMappingURL=upload.js.map