gtx-cli 2.6.31 → 2.7.0

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 (348) hide show
  1. package/CHANGELOG.md +4 -1261
  2. package/README.md +12 -3
  3. package/dist/bin/bin-entry.js +2 -1
  4. package/dist/config/generateSettings.d.ts +1 -9
  5. package/dist/config/generateSettings.js +1 -214
  6. package/dist/config/resolveConfig.d.ts +1 -4
  7. package/dist/config/resolveConfig.js +1 -33
  8. package/dist/fs/config/setupConfig.d.ts +1 -17
  9. package/dist/fs/config/setupConfig.js +1 -50
  10. package/dist/fs/matchFiles.d.ts +1 -1
  11. package/dist/fs/matchFiles.js +1 -8
  12. package/dist/functions.d.ts +1 -7
  13. package/dist/functions.js +1 -6
  14. package/dist/index.d.ts +1 -4
  15. package/dist/index.js +1 -27
  16. package/dist/main.js +2 -2
  17. package/dist/next/parse/handleInitGT.d.ts +1 -7
  18. package/dist/next/parse/handleInitGT.js +1 -157
  19. package/dist/next/parse/wrapContent.d.ts +1 -12
  20. package/dist/next/parse/wrapContent.js +1 -164
  21. package/dist/react/parse/wrapContent.d.ts +1 -12
  22. package/dist/react/parse/wrapContent.js +1 -162
  23. package/dist/types/index.d.ts +1 -243
  24. package/dist/types/index.js +1 -1
  25. package/dist/utils/installPackage.d.ts +1 -3
  26. package/dist/utils/installPackage.js +1 -77
  27. package/dist/utils/packageInfo.d.ts +1 -3
  28. package/dist/utils/packageInfo.js +1 -17
  29. package/dist/utils/packageJson.d.ts +1 -6
  30. package/dist/utils/packageJson.js +1 -68
  31. package/dist/utils/packageManager.d.ts +1 -28
  32. package/dist/utils/packageManager.js +1 -269
  33. package/package.json +11 -97
  34. package/dist/api/collectUserEditDiffs.d.ts +0 -9
  35. package/dist/api/collectUserEditDiffs.js +0 -159
  36. package/dist/api/downloadFileBatch.d.ts +0 -23
  37. package/dist/api/downloadFileBatch.js +0 -190
  38. package/dist/api/saveLocalEdits.d.ts +0 -6
  39. package/dist/api/saveLocalEdits.js +0 -38
  40. package/dist/cli/base.d.ts +0 -59
  41. package/dist/cli/base.js +0 -529
  42. package/dist/cli/commands/download.d.ts +0 -8
  43. package/dist/cli/commands/download.js +0 -51
  44. package/dist/cli/commands/enqueue.d.ts +0 -9
  45. package/dist/cli/commands/enqueue.js +0 -27
  46. package/dist/cli/commands/setupProject.d.ts +0 -7
  47. package/dist/cli/commands/setupProject.js +0 -37
  48. package/dist/cli/commands/stage.d.ts +0 -9
  49. package/dist/cli/commands/stage.js +0 -59
  50. package/dist/cli/commands/translate.d.ts +0 -7
  51. package/dist/cli/commands/translate.js +0 -70
  52. package/dist/cli/commands/upload.d.ts +0 -13
  53. package/dist/cli/commands/upload.js +0 -142
  54. package/dist/cli/commands/utils/validation.d.ts +0 -13
  55. package/dist/cli/commands/utils/validation.js +0 -38
  56. package/dist/cli/flags.d.ts +0 -15
  57. package/dist/cli/flags.js +0 -70
  58. package/dist/cli/inline.d.ts +0 -17
  59. package/dist/cli/inline.js +0 -135
  60. package/dist/cli/next.d.ts +0 -10
  61. package/dist/cli/next.js +0 -12
  62. package/dist/cli/node.d.ts +0 -10
  63. package/dist/cli/node.js +0 -9
  64. package/dist/cli/react.d.ts +0 -12
  65. package/dist/cli/react.js +0 -72
  66. package/dist/config/optionPresets.d.ts +0 -3
  67. package/dist/config/optionPresets.js +0 -65
  68. package/dist/config/utils.d.ts +0 -2
  69. package/dist/config/utils.js +0 -4
  70. package/dist/config/validateSettings.d.ts +0 -3
  71. package/dist/config/validateSettings.js +0 -32
  72. package/dist/console/colors.d.ts +0 -6
  73. package/dist/console/colors.js +0 -19
  74. package/dist/console/displayTranslateSummary.d.ts +0 -1
  75. package/dist/console/displayTranslateSummary.js +0 -42
  76. package/dist/console/formatting.d.ts +0 -1
  77. package/dist/console/formatting.js +0 -7
  78. package/dist/console/index.d.ts +0 -34
  79. package/dist/console/index.js +0 -46
  80. package/dist/console/logger.d.ts +0 -35
  81. package/dist/console/logger.js +0 -250
  82. package/dist/console/logging.d.ts +0 -52
  83. package/dist/console/logging.js +0 -175
  84. package/dist/formats/files/aggregateFiles.d.ts +0 -4
  85. package/dist/formats/files/aggregateFiles.js +0 -156
  86. package/dist/formats/files/collectFiles.d.ts +0 -6
  87. package/dist/formats/files/collectFiles.js +0 -49
  88. package/dist/formats/files/convertToFileTranslationData.d.ts +0 -15
  89. package/dist/formats/files/convertToFileTranslationData.js +0 -21
  90. package/dist/formats/files/fileMapping.d.ts +0 -11
  91. package/dist/formats/files/fileMapping.js +0 -115
  92. package/dist/formats/files/preprocess/mdx.d.ts +0 -6
  93. package/dist/formats/files/preprocess/mdx.js +0 -14
  94. package/dist/formats/files/preprocess/mintlify.d.ts +0 -5
  95. package/dist/formats/files/preprocess/mintlify.js +0 -15
  96. package/dist/formats/files/preprocessContent.d.ts +0 -8
  97. package/dist/formats/files/preprocessContent.js +0 -23
  98. package/dist/formats/files/save.d.ts +0 -5
  99. package/dist/formats/files/save.js +0 -17
  100. package/dist/formats/files/supportedFiles.d.ts +0 -11
  101. package/dist/formats/files/supportedFiles.js +0 -20
  102. package/dist/formats/json/extractJson.d.ts +0 -15
  103. package/dist/formats/json/extractJson.js +0 -101
  104. package/dist/formats/json/flattenJson.d.ts +0 -14
  105. package/dist/formats/json/flattenJson.js +0 -64
  106. package/dist/formats/json/mergeJson.d.ts +0 -13
  107. package/dist/formats/json/mergeJson.js +0 -367
  108. package/dist/formats/json/parseJson.d.ts +0 -2
  109. package/dist/formats/json/parseJson.js +0 -109
  110. package/dist/formats/json/utils.d.ts +0 -47
  111. package/dist/formats/json/utils.js +0 -150
  112. package/dist/formats/utils.d.ts +0 -2
  113. package/dist/formats/utils.js +0 -24
  114. package/dist/formats/yaml/mergeYaml.d.ts +0 -5
  115. package/dist/formats/yaml/mergeYaml.js +0 -61
  116. package/dist/formats/yaml/parseYaml.d.ts +0 -5
  117. package/dist/formats/yaml/parseYaml.js +0 -24
  118. package/dist/formats/yaml/utils.d.ts +0 -2
  119. package/dist/formats/yaml/utils.js +0 -23
  120. package/dist/fs/clearLocaleDirs.d.ts +0 -8
  121. package/dist/fs/clearLocaleDirs.js +0 -126
  122. package/dist/fs/config/downloadedVersions.d.ts +0 -21
  123. package/dist/fs/config/downloadedVersions.js +0 -50
  124. package/dist/fs/config/loadConfig.d.ts +0 -1
  125. package/dist/fs/config/loadConfig.js +0 -9
  126. package/dist/fs/config/parseFilesConfig.d.ts +0 -27
  127. package/dist/fs/config/parseFilesConfig.js +0 -150
  128. package/dist/fs/config/updateConfig.d.ts +0 -21
  129. package/dist/fs/config/updateConfig.js +0 -57
  130. package/dist/fs/config/updateVersions.d.ts +0 -11
  131. package/dist/fs/config/updateVersions.js +0 -30
  132. package/dist/fs/copyFile.d.ts +0 -7
  133. package/dist/fs/copyFile.js +0 -39
  134. package/dist/fs/createLoadTranslationsFile.d.ts +0 -1
  135. package/dist/fs/createLoadTranslationsFile.js +0 -49
  136. package/dist/fs/determineFramework.d.ts +0 -5
  137. package/dist/fs/determineFramework.js +0 -53
  138. package/dist/fs/findFilepath.d.ts +0 -36
  139. package/dist/fs/findFilepath.js +0 -90
  140. package/dist/fs/index.d.ts +0 -1
  141. package/dist/fs/index.js +0 -1
  142. package/dist/fs/loadJSON.d.ts +0 -6
  143. package/dist/fs/loadJSON.js +0 -17
  144. package/dist/fs/saveJSON.d.ts +0 -1
  145. package/dist/fs/saveJSON.js +0 -7
  146. package/dist/fs/utils.d.ts +0 -1
  147. package/dist/fs/utils.js +0 -16
  148. package/dist/generated/version.d.ts +0 -1
  149. package/dist/generated/version.js +0 -2
  150. package/dist/git/branches.d.ts +0 -7
  151. package/dist/git/branches.js +0 -88
  152. package/dist/hooks/postProcess.d.ts +0 -4
  153. package/dist/hooks/postProcess.js +0 -110
  154. package/dist/locadex/setupFlow.d.ts +0 -2
  155. package/dist/locadex/setupFlow.js +0 -9
  156. package/dist/next/config/parseNextConfig.d.ts +0 -10
  157. package/dist/next/config/parseNextConfig.js +0 -53
  158. package/dist/next/jsx/utils.d.ts +0 -7
  159. package/dist/next/jsx/utils.js +0 -42
  160. package/dist/react/config/createESBuildConfig.d.ts +0 -2
  161. package/dist/react/config/createESBuildConfig.js +0 -119
  162. package/dist/react/jsx/evaluateJsx.d.ts +0 -24
  163. package/dist/react/jsx/evaluateJsx.js +0 -123
  164. package/dist/react/jsx/utils/buildImportMap.d.ts +0 -9
  165. package/dist/react/jsx/utils/buildImportMap.js +0 -30
  166. package/dist/react/jsx/utils/constants.d.ts +0 -15
  167. package/dist/react/jsx/utils/constants.js +0 -49
  168. package/dist/react/jsx/utils/getCalleeNameFromExpression.d.ts +0 -9
  169. package/dist/react/jsx/utils/getCalleeNameFromExpression.js +0 -32
  170. package/dist/react/jsx/utils/getPathsAndAliases.d.ts +0 -21
  171. package/dist/react/jsx/utils/getPathsAndAliases.js +0 -91
  172. package/dist/react/jsx/utils/isNumberLiteral.d.ts +0 -7
  173. package/dist/react/jsx/utils/isNumberLiteral.js +0 -13
  174. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.d.ts +0 -9
  175. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +0 -138
  176. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.d.ts +0 -6
  177. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +0 -197
  178. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.d.ts +0 -13
  179. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +0 -42
  180. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.d.ts +0 -5
  181. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +0 -69
  182. package/dist/react/jsx/utils/jsxParsing/parseJsx.d.ts +0 -33
  183. package/dist/react/jsx/utils/jsxParsing/parseJsx.js +0 -918
  184. package/dist/react/jsx/utils/jsxParsing/parseTProps.d.ts +0 -8
  185. package/dist/react/jsx/utils/jsxParsing/parseTProps.js +0 -65
  186. package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.d.ts +0 -2
  187. package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +0 -61
  188. package/dist/react/jsx/utils/jsxParsing/types.d.ts +0 -48
  189. package/dist/react/jsx/utils/jsxParsing/types.js +0 -34
  190. package/dist/react/jsx/utils/mapAttributeName.d.ts +0 -11
  191. package/dist/react/jsx/utils/mapAttributeName.js +0 -12
  192. package/dist/react/jsx/utils/parseAst.d.ts +0 -31
  193. package/dist/react/jsx/utils/parseAst.js +0 -278
  194. package/dist/react/jsx/utils/parseDeclareStatic.d.ts +0 -15
  195. package/dist/react/jsx/utils/parseDeclareStatic.js +0 -540
  196. package/dist/react/jsx/utils/parseString.d.ts +0 -25
  197. package/dist/react/jsx/utils/parseString.js +0 -540
  198. package/dist/react/jsx/utils/parseStringFunction.d.ts +0 -30
  199. package/dist/react/jsx/utils/parseStringFunction.js +0 -348
  200. package/dist/react/jsx/utils/resolveImportPath.d.ts +0 -11
  201. package/dist/react/jsx/utils/resolveImportPath.js +0 -111
  202. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.d.ts +0 -29
  203. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +0 -86
  204. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.d.ts +0 -14
  205. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +0 -24
  206. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.d.ts +0 -19
  207. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +0 -31
  208. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.d.ts +0 -22
  209. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.js +0 -51
  210. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.d.ts +0 -18
  211. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +0 -39
  212. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.d.ts +0 -24
  213. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +0 -68
  214. package/dist/react/jsx/utils/stringParsing/types.d.ts +0 -41
  215. package/dist/react/jsx/utils/stringParsing/types.js +0 -1
  216. package/dist/react/jsx/utils/types.d.ts +0 -14
  217. package/dist/react/jsx/utils/types.js +0 -1
  218. package/dist/react/jsx/utils/validateStringFunction.d.ts +0 -7
  219. package/dist/react/jsx/utils/validateStringFunction.js +0 -31
  220. package/dist/react/jsx/wrapJsx.d.ts +0 -51
  221. package/dist/react/jsx/wrapJsx.js +0 -387
  222. package/dist/react/parse/addVitePlugin/index.d.ts +0 -22
  223. package/dist/react/parse/addVitePlugin/index.js +0 -41
  224. package/dist/react/parse/addVitePlugin/installCompiler.d.ts +0 -8
  225. package/dist/react/parse/addVitePlugin/installCompiler.js +0 -22
  226. package/dist/react/parse/addVitePlugin/updateViteConfig.d.ts +0 -19
  227. package/dist/react/parse/addVitePlugin/updateViteConfig.js +0 -120
  228. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.d.ts +0 -9
  229. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +0 -34
  230. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.d.ts +0 -11
  231. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +0 -48
  232. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.d.ts +0 -15
  233. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +0 -113
  234. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.d.ts +0 -12
  235. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +0 -32
  236. package/dist/react/parse/createDictionaryUpdates.d.ts +0 -3
  237. package/dist/react/parse/createDictionaryUpdates.js +0 -187
  238. package/dist/react/parse/createInlineUpdates.d.ts +0 -13
  239. package/dist/react/parse/createInlineUpdates.js +0 -161
  240. package/dist/react/utils/flattenDictionary.d.ts +0 -20
  241. package/dist/react/utils/flattenDictionary.js +0 -75
  242. package/dist/react/utils/getEntryAndMetadata.d.ts +0 -5
  243. package/dist/react/utils/getEntryAndMetadata.js +0 -11
  244. package/dist/react/utils/getVariableName.d.ts +0 -25
  245. package/dist/react/utils/getVariableName.js +0 -37
  246. package/dist/setup/agentInstructions.d.ts +0 -24
  247. package/dist/setup/agentInstructions.js +0 -138
  248. package/dist/setup/detectFramework.d.ts +0 -31
  249. package/dist/setup/detectFramework.js +0 -106
  250. package/dist/setup/frameworkUtils.d.ts +0 -3
  251. package/dist/setup/frameworkUtils.js +0 -30
  252. package/dist/setup/instructions/base.md +0 -29
  253. package/dist/setup/instructions/gt-next.md +0 -107
  254. package/dist/setup/instructions/gt-react.md +0 -98
  255. package/dist/setup/userInput.d.ts +0 -4
  256. package/dist/setup/userInput.js +0 -32
  257. package/dist/setup/wizard.d.ts +0 -3
  258. package/dist/setup/wizard.js +0 -147
  259. package/dist/state/recentDownloads.d.ts +0 -12
  260. package/dist/state/recentDownloads.js +0 -18
  261. package/dist/state/translateWarnings.d.ts +0 -10
  262. package/dist/state/translateWarnings.js +0 -13
  263. package/dist/translation/parse.d.ts +0 -17
  264. package/dist/translation/parse.js +0 -77
  265. package/dist/translation/stage.d.ts +0 -3
  266. package/dist/translation/stage.js +0 -44
  267. package/dist/translation/validate.d.ts +0 -14
  268. package/dist/translation/validate.js +0 -100
  269. package/dist/types/branch.d.ts +0 -14
  270. package/dist/types/branch.js +0 -1
  271. package/dist/types/data/json.d.ts +0 -6
  272. package/dist/types/data/json.js +0 -1
  273. package/dist/types/data.d.ts +0 -37
  274. package/dist/types/data.js +0 -1
  275. package/dist/types/files.d.ts +0 -8
  276. package/dist/types/files.js +0 -1
  277. package/dist/types/libraries.d.ts +0 -31
  278. package/dist/types/libraries.js +0 -72
  279. package/dist/types/parsing.d.ts +0 -3
  280. package/dist/types/parsing.js +0 -1
  281. package/dist/utils/addExplicitAnchorIds.d.ts +0 -24
  282. package/dist/utils/addExplicitAnchorIds.js +0 -416
  283. package/dist/utils/constants.d.ts +0 -5
  284. package/dist/utils/constants.js +0 -6
  285. package/dist/utils/credentials.d.ts +0 -12
  286. package/dist/utils/credentials.js +0 -120
  287. package/dist/utils/flattenJsonFiles.d.ts +0 -2
  288. package/dist/utils/flattenJsonFiles.js +0 -36
  289. package/dist/utils/gitDiff.d.ts +0 -8
  290. package/dist/utils/gitDiff.js +0 -34
  291. package/dist/utils/gt.d.ts +0 -2
  292. package/dist/utils/gt.js +0 -2
  293. package/dist/utils/hash.d.ts +0 -6
  294. package/dist/utils/hash.js +0 -11
  295. package/dist/utils/headers.d.ts +0 -1
  296. package/dist/utils/headers.js +0 -14
  297. package/dist/utils/localizeRelativeAssets.d.ts +0 -8
  298. package/dist/utils/localizeRelativeAssets.js +0 -166
  299. package/dist/utils/localizeStaticImports.d.ts +0 -15
  300. package/dist/utils/localizeStaticImports.js +0 -397
  301. package/dist/utils/localizeStaticUrls.d.ts +0 -19
  302. package/dist/utils/localizeStaticUrls.js +0 -450
  303. package/dist/utils/mintlifyTitleFallback.d.ts +0 -6
  304. package/dist/utils/mintlifyTitleFallback.js +0 -80
  305. package/dist/utils/parse/needsCJS.d.ts +0 -20
  306. package/dist/utils/parse/needsCJS.js +0 -72
  307. package/dist/utils/persistPostprocessHashes.d.ts +0 -12
  308. package/dist/utils/persistPostprocessHashes.js +0 -39
  309. package/dist/utils/processAnchorIds.d.ts +0 -6
  310. package/dist/utils/processAnchorIds.js +0 -56
  311. package/dist/utils/processOpenApi.d.ts +0 -8
  312. package/dist/utils/processOpenApi.js +0 -651
  313. package/dist/utils/sanitizeFileContent.d.ts +0 -6
  314. package/dist/utils/sanitizeFileContent.js +0 -29
  315. package/dist/utils/sharedStaticAssets.d.ts +0 -9
  316. package/dist/utils/sharedStaticAssets.js +0 -384
  317. package/dist/utils/validateMdx.d.ts +0 -10
  318. package/dist/utils/validateMdx.js +0 -25
  319. package/dist/utils/wrapPlainUrls.d.ts +0 -8
  320. package/dist/utils/wrapPlainUrls.js +0 -72
  321. package/dist/workflows/download.d.ts +0 -32
  322. package/dist/workflows/download.js +0 -131
  323. package/dist/workflows/enqueue.d.ts +0 -17
  324. package/dist/workflows/enqueue.js +0 -59
  325. package/dist/workflows/setupProject.d.ts +0 -13
  326. package/dist/workflows/setupProject.js +0 -48
  327. package/dist/workflows/stage.d.ts +0 -18
  328. package/dist/workflows/stage.js +0 -59
  329. package/dist/workflows/steps/BranchStep.d.ts +0 -13
  330. package/dist/workflows/steps/BranchStep.js +0 -161
  331. package/dist/workflows/steps/DownloadStep.d.ts +0 -19
  332. package/dist/workflows/steps/DownloadStep.js +0 -131
  333. package/dist/workflows/steps/EnqueueStep.d.ts +0 -15
  334. package/dist/workflows/steps/EnqueueStep.js +0 -33
  335. package/dist/workflows/steps/PollJobsStep.d.ts +0 -31
  336. package/dist/workflows/steps/PollJobsStep.js +0 -288
  337. package/dist/workflows/steps/SetupStep.d.ts +0 -16
  338. package/dist/workflows/steps/SetupStep.js +0 -72
  339. package/dist/workflows/steps/UploadSourcesStep.d.ts +0 -27
  340. package/dist/workflows/steps/UploadSourcesStep.js +0 -131
  341. package/dist/workflows/steps/UploadTranslationsStep.d.ts +0 -22
  342. package/dist/workflows/steps/UploadTranslationsStep.js +0 -71
  343. package/dist/workflows/steps/UserEditDiffsStep.d.ts +0 -11
  344. package/dist/workflows/steps/UserEditDiffsStep.js +0 -30
  345. package/dist/workflows/steps/WorkflowStep.d.ts +0 -4
  346. package/dist/workflows/steps/WorkflowStep.js +0 -2
  347. package/dist/workflows/upload.d.ts +0 -15
  348. package/dist/workflows/upload.js +0 -47
@@ -1,37 +0,0 @@
1
- import { logger } from '../../console/logger.js';
2
- import { exitSync, logCollectedFiles } from '../../console/logging.js';
3
- import { collectFiles } from '../../formats/files/collectFiles.js';
4
- import { runSetupProjectWorkflow } from '../../workflows/setupProject.js';
5
- import { hasValidCredentials, hasValidLocales } from './utils/validation.js';
6
- export async function handleSetupProject(options, settings, library) {
7
- if (!hasValidLocales(settings))
8
- return exitSync(1);
9
- // Validate credentials if not in dry run
10
- if (!options.dryRun && !hasValidCredentials(settings))
11
- return exitSync(1);
12
- const { files: allFiles, reactComponents } = await collectFiles(options, settings, library);
13
- // Dry run
14
- if (options.dryRun) {
15
- logger.success(`Dry run: No files were uploaded to General Translation.`);
16
- logCollectedFiles(allFiles, reactComponents);
17
- return null;
18
- }
19
- // Upload files and run setup step
20
- let fileVersionData;
21
- let branchData;
22
- if (allFiles.length > 0) {
23
- const { branchData: branchDataResult } = await runSetupProjectWorkflow(allFiles, options, settings);
24
- branchData = branchDataResult;
25
- fileVersionData = Object.fromEntries(allFiles.map((file) => [
26
- file.fileId,
27
- {
28
- fileName: file.fileName,
29
- versionId: file.versionId,
30
- },
31
- ]));
32
- }
33
- return {
34
- fileVersionData,
35
- branchData,
36
- };
37
- }
@@ -1,9 +0,0 @@
1
- import { Settings, SupportedLibraries, TranslateFlags } from '../../types/index.js';
2
- import type { EnqueueFilesResult } from 'generaltranslation/types';
3
- import { FileTranslationData } from '../../workflows/download.js';
4
- import { BranchData } from '../../types/branch.js';
5
- export declare function handleStage(options: TranslateFlags, settings: Settings, library: SupportedLibraries, stage: boolean): Promise<{
6
- fileVersionData: FileTranslationData | undefined;
7
- jobData: EnqueueFilesResult | undefined;
8
- branchData: BranchData | undefined;
9
- } | null>;
@@ -1,59 +0,0 @@
1
- import { logger } from '../../console/logger.js';
2
- import { exitSync, logCollectedFiles } from '../../console/logging.js';
3
- import { runStageFilesWorkflow } from '../../workflows/stage.js';
4
- import { updateVersions } from '../../fs/config/updateVersions.js';
5
- import updateConfig from '../../fs/config/updateConfig.js';
6
- import { TEMPLATE_FILE_ID } from '../../utils/constants.js';
7
- import { collectFiles } from '../../formats/files/collectFiles.js';
8
- import { convertToFileTranslationData } from '../../formats/files/convertToFileTranslationData.js';
9
- import { hasValidCredentials, hasValidLocales } from './utils/validation.js';
10
- export async function handleStage(options, settings, library, stage) {
11
- if (!hasValidLocales(settings))
12
- return exitSync(1);
13
- // Validate credentials if not in dry run
14
- if (!options.dryRun && !hasValidCredentials(settings))
15
- return exitSync(1);
16
- const { files: allFiles, reactComponents } = await collectFiles(options, settings, library);
17
- // Dry run
18
- if (options.dryRun) {
19
- logger.success(`Dry run: No files were sent to General Translation.`);
20
- logCollectedFiles(allFiles, reactComponents);
21
- return null;
22
- }
23
- // Send translations to General Translation
24
- let fileVersionData;
25
- let jobData;
26
- let branchData;
27
- if (allFiles.length > 0) {
28
- const { branchData: branchDataResult, enqueueResult } = await runStageFilesWorkflow({ files: allFiles, options, settings });
29
- jobData = enqueueResult;
30
- branchData = branchDataResult;
31
- fileVersionData = convertToFileTranslationData(allFiles);
32
- // This logic is a little scuffed because stage is async from the API
33
- if (stage) {
34
- await updateVersions({
35
- configDirectory: settings.configDirectory,
36
- versionData: fileVersionData,
37
- });
38
- }
39
- const templateData = allFiles.find((file) => file.fileId === TEMPLATE_FILE_ID);
40
- if (templateData?.versionId) {
41
- await updateConfig(settings.config, {
42
- _versionId: templateData.versionId,
43
- _branchId: branchData.currentBranch.id,
44
- });
45
- }
46
- }
47
- // Always delete branch id from config if branching is disabled
48
- // Avoids incorrect CDN queries at runtime
49
- if (!settings.branchOptions.enabled) {
50
- await updateConfig(settings.config, {
51
- _branchId: null,
52
- });
53
- }
54
- return {
55
- fileVersionData,
56
- jobData,
57
- branchData,
58
- };
59
- }
@@ -1,7 +0,0 @@
1
- import { EnqueueFilesResult } from 'generaltranslation/types';
2
- import { TranslateFlags } from '../../types/index.js';
3
- import { Settings } from '../../types/index.js';
4
- import { FileTranslationData } from '../../workflows/download.js';
5
- import { BranchData } from '../../types/branch.js';
6
- export declare function handleTranslate(options: TranslateFlags, settings: Settings, fileVersionData: FileTranslationData | undefined, jobData: EnqueueFilesResult | undefined, branchData: BranchData | undefined): Promise<void>;
7
- export declare function postProcessTranslations(settings: Settings, includeFiles?: Set<string>): Promise<void>;
@@ -1,70 +0,0 @@
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
- // Downloads translations that were completed
13
- export async function handleTranslate(options, settings, fileVersionData, jobData, branchData) {
14
- if (fileVersionData) {
15
- const { resolvedPaths, placeholderPaths, transformPaths } = settings.files;
16
- const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, settings.locales, settings.defaultLocale);
17
- // Check for remaining translations
18
- await runDownloadWorkflow({
19
- fileVersionData: fileVersionData,
20
- jobData: jobData,
21
- branchData: branchData,
22
- locales: settings.locales,
23
- timeoutDuration: options.timeout,
24
- resolveOutputPath: (sourcePath, locale) => fileMapping[locale]?.[sourcePath] ?? null,
25
- options: settings,
26
- forceRetranslation: options.force,
27
- forceDownload: options.forceDownload || options.force, // if force is true should also force download
28
- });
29
- }
30
- }
31
- export async function postProcessTranslations(settings, includeFiles) {
32
- // Mintlify OpenAPI localization (spec routing + validation)
33
- await processOpenApi(settings, includeFiles);
34
- // Localize static urls (/docs -> /[locale]/docs) and preserve anchor IDs for non-default locales
35
- // Default locale is processed earlier in the flow in base.ts
36
- if (settings.options?.experimentalLocalizeStaticUrls) {
37
- const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
38
- if (nonDefaultLocales.length > 0) {
39
- await localizeStaticUrls(settings, nonDefaultLocales, includeFiles);
40
- }
41
- }
42
- // Rewrite relative asset URLs in translated md/mdx files
43
- if (settings.options?.experimentalLocalizeRelativeAssets) {
44
- const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
45
- if (nonDefaultLocales.length > 0) {
46
- await localizeRelativeAssets(settings, nonDefaultLocales, includeFiles);
47
- }
48
- }
49
- const shouldProcessAnchorIds = settings.options?.experimentalLocalizeStaticUrls ||
50
- settings.options?.experimentalAddHeaderAnchorIds;
51
- // Add explicit anchor IDs to translated MDX/MD files to preserve navigation
52
- // Uses inline {#id} format by default, or div wrapping if experimentalAddHeaderAnchorIds is 'mintlify'
53
- if (shouldProcessAnchorIds) {
54
- await processAnchorIds(settings, includeFiles);
55
- }
56
- // Localize static imports (import Snippet from /snippets/file.mdx -> import Snippet from /snippets/[locale]/file.mdx)
57
- if (settings.options?.experimentalLocalizeStaticImports) {
58
- await localizeStaticImports(settings, includeFiles);
59
- }
60
- // Flatten json files into a single file
61
- if (settings.options?.experimentalFlattenJsonFiles) {
62
- await flattenJsonFiles(settings, includeFiles);
63
- }
64
- // Copy files to the target locale
65
- if (settings.options?.copyFiles) {
66
- await copyFile(settings);
67
- }
68
- // Record postprocessed content hashes for newly downloaded files
69
- persistPostProcessHashes(settings, includeFiles, getDownloadedMeta());
70
- }
@@ -1,13 +0,0 @@
1
- import { ResolvedFiles, Settings, TransformFiles } from '../../types/index.js';
2
- import { DataFormat } from '../../types/data.js';
3
- import { UploadOptions } from '../base.js';
4
- /**
5
- * Sends multiple files to the API for translation
6
- * @param filePaths - Resolved file paths for different file types
7
- * @param placeholderPaths - Placeholder paths for translated files
8
- * @param transformPaths - Transform paths for file naming
9
- * @param dataFormat - Format of the data within the files
10
- * @param settings - Translation options including API settings
11
- * @returns Promise that resolves when translation is complete
12
- */
13
- export declare function upload(filePaths: ResolvedFiles, placeholderPaths: ResolvedFiles, transformPaths: TransformFiles, dataFormat: DataFormat | undefined, settings: Settings & UploadOptions): Promise<void>;
@@ -1,142 +0,0 @@
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 { runUploadFilesWorkflow } from '../../workflows/upload.js';
9
- import { existsSync, readFileSync } from 'node:fs';
10
- import { createFileMapping } from '../../formats/files/fileMapping.js';
11
- import parseYaml from '../../formats/yaml/parseYaml.js';
12
- import { hashStringSync } from '../../utils/hash.js';
13
- import { hasValidCredentials } from './utils/validation.js';
14
- const SUPPORTED_DATA_FORMATS = ['JSX', 'ICU', 'I18NEXT'];
15
- /**
16
- * Sends multiple files to the API for translation
17
- * @param filePaths - Resolved file paths for different file types
18
- * @param placeholderPaths - Placeholder paths for translated files
19
- * @param transformPaths - Transform paths for file naming
20
- * @param dataFormat - Format of the data within the files
21
- * @param settings - Translation options including API settings
22
- * @returns Promise that resolves when translation is complete
23
- */
24
- export async function upload(filePaths, placeholderPaths, transformPaths, dataFormat = 'JSX', settings) {
25
- // Collect all files to translate
26
- const allFiles = [];
27
- const additionalOptions = settings.options || {};
28
- // Process JSON files
29
- if (filePaths.json) {
30
- if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) {
31
- logErrorAndExit(noSupportedFormatError);
32
- }
33
- const jsonFiles = filePaths.json.map((filePath) => {
34
- const content = readFile(filePath);
35
- const parsedJson = parseJson(content, filePath, additionalOptions, settings.defaultLocale);
36
- const relativePath = getRelative(filePath);
37
- return {
38
- content: parsedJson,
39
- fileName: relativePath,
40
- fileFormat: 'JSON',
41
- dataFormat,
42
- locale: settings.defaultLocale,
43
- fileId: hashStringSync(relativePath),
44
- versionId: hashStringSync(parsedJson),
45
- };
46
- });
47
- allFiles.push(...jsonFiles);
48
- }
49
- // Process YAML files
50
- if (filePaths.yaml) {
51
- if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) {
52
- logErrorAndExit(noSupportedFormatError);
53
- }
54
- const yamlFiles = filePaths.yaml.map((filePath) => {
55
- const content = readFile(filePath);
56
- const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, additionalOptions);
57
- const relativePath = getRelative(filePath);
58
- return {
59
- content: parsedYaml,
60
- fileName: relativePath,
61
- fileFormat,
62
- dataFormat,
63
- locale: settings.defaultLocale,
64
- fileId: hashStringSync(relativePath),
65
- versionId: hashStringSync(parsedYaml),
66
- };
67
- });
68
- allFiles.push(...yamlFiles);
69
- }
70
- for (const fileType of SUPPORTED_FILE_EXTENSIONS) {
71
- if (fileType === 'json' || fileType === 'yaml')
72
- continue;
73
- if (filePaths[fileType]) {
74
- const files = filePaths[fileType].map((filePath) => {
75
- const content = readFile(filePath);
76
- const sanitizedContent = sanitizeFileContent(content);
77
- const relativePath = getRelative(filePath);
78
- return {
79
- content: sanitizedContent,
80
- fileName: relativePath,
81
- fileFormat: fileType.toUpperCase(),
82
- dataFormat,
83
- locale: settings.defaultLocale,
84
- fileId: hashStringSync(relativePath),
85
- versionId: hashStringSync(sanitizedContent),
86
- };
87
- });
88
- allFiles.push(...files);
89
- }
90
- }
91
- if (allFiles.length === 0) {
92
- logger.error('No files to upload were found. Please check your configuration and try again.');
93
- return;
94
- }
95
- if (!settings.defaultLocale) {
96
- return logErrorAndExit(noDefaultLocaleError);
97
- }
98
- if (!hasValidCredentials(settings))
99
- return exitSync(1);
100
- const locales = settings.locales || [];
101
- // Create file mapping for all file types
102
- const fileMapping = createFileMapping(filePaths, placeholderPaths, transformPaths, locales, settings.defaultLocale);
103
- // construct object
104
- const uploadData = allFiles.map((file) => {
105
- const sourceFile = {
106
- content: file.content,
107
- fileName: file.fileName,
108
- fileFormat: file.fileFormat,
109
- dataFormat: file.dataFormat,
110
- locale: file.locale,
111
- fileId: file.fileId,
112
- versionId: file.versionId,
113
- };
114
- const translations = [];
115
- for (const locale of locales) {
116
- const translatedFileName = fileMapping[locale][file.fileName];
117
- if (translatedFileName && existsSync(translatedFileName)) {
118
- const translatedContent = readFileSync(translatedFileName, 'utf8');
119
- translations.push({
120
- content: translatedContent,
121
- fileName: file.fileName,
122
- fileFormat: file.fileFormat,
123
- dataFormat: file.dataFormat,
124
- locale,
125
- fileId: file.fileId,
126
- versionId: file.versionId,
127
- });
128
- }
129
- }
130
- return {
131
- source: sourceFile,
132
- translations,
133
- };
134
- });
135
- try {
136
- // Send all files in a single API call
137
- await runUploadFilesWorkflow({ files: uploadData, options: settings });
138
- }
139
- catch (error) {
140
- logErrorAndExit(`Error uploading files: ${error}`);
141
- }
142
- }
@@ -1,13 +0,0 @@
1
- import { Settings } from '../../../types/index.js';
2
- /**
3
- * Validate locales
4
- * @param settings - The settings to validate
5
- * @returns True if has locales and default locale
6
- */
7
- export declare function hasValidLocales(settings: Settings): boolean;
8
- /**
9
- * Validate credentials
10
- * @param settings - The settings to validate
11
- * @returns True if has API key, project ID, and does not have a development API key
12
- */
13
- export declare function hasValidCredentials(settings: Settings): boolean;
@@ -1,38 +0,0 @@
1
- import { noDefaultLocaleError, noLocalesError, noApiKeyError, devApiKeyError, noProjectIdError, } from '../../../console/index.js';
2
- import { logger } from '../../../console/logger.js';
3
- /**
4
- * Validate locales
5
- * @param settings - The settings to validate
6
- * @returns True if has locales and default locale
7
- */
8
- export function hasValidLocales(settings) {
9
- if (!settings.locales) {
10
- logger.error(noLocalesError);
11
- return false;
12
- }
13
- if (!settings.defaultLocale) {
14
- logger.error(noDefaultLocaleError);
15
- return false;
16
- }
17
- return true;
18
- }
19
- /**
20
- * Validate credentials
21
- * @param settings - The settings to validate
22
- * @returns True if has API key, project ID, and does not have a development API key
23
- */
24
- export function hasValidCredentials(settings) {
25
- if (!settings.apiKey) {
26
- logger.error(noApiKeyError);
27
- return false;
28
- }
29
- if (settings.apiKey.startsWith('gtx-dev-')) {
30
- logger.error(devApiKeyError);
31
- return false;
32
- }
33
- if (!settings.projectId) {
34
- logger.error(noProjectIdError);
35
- return false;
36
- }
37
- return true;
38
- }
@@ -1,15 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function attachSharedFlags(command: Command): Command;
3
- export declare function attachTranslateFlags(command: Command): Command;
4
- /**
5
- * Attaches flags necessary for validating a project
6
- * @param command
7
- * @returns The command with the validate flags attached
8
- */
9
- export declare function attachValidateFlags(command: Command): Command;
10
- /**
11
- * Attaches flags necessary for translating a project
12
- * @param command
13
- * @returns The command with the translate flags attached
14
- */
15
- export declare function attachInlineTranslateFlags(command: Command): Command;
package/dist/cli/flags.js DELETED
@@ -1,70 +0,0 @@
1
- import findFilepath from '../fs/findFilepath.js';
2
- import { DEFAULT_GIT_REMOTE_NAME } from '../utils/constants.js';
3
- const DEFAULT_TIMEOUT = 600;
4
- export function attachSharedFlags(command) {
5
- command
6
- .option('-c, --config <path>', 'Filepath to config file, by default gt.config.json', findFilepath(['gt.config.json']))
7
- .option('--api-key <key>', 'API key for General Translation cloud service')
8
- .option('--project-id <id>', 'General Translation project ID');
9
- return command;
10
- }
11
- export function attachTranslateFlags(command) {
12
- attachSharedFlags(command)
13
- .option('--version-id <id>', 'General Translation version ID')
14
- .option('--default-language, --default-locale <locale>', 'Default locale (e.g., en)')
15
- .option('--new, --locales <locales...>', 'Space-separated list of locales (e.g., en fr es)')
16
- .option('--dry-run', 'Dry run, do not send updates to the General Translation API', false)
17
- .option('--timeout <seconds>', 'Translation wait timeout in seconds', (value) => {
18
- const parsedValue = parseInt(value, 10);
19
- if (isNaN(parsedValue)) {
20
- throw new Error('Invalid timeout: not a number.');
21
- }
22
- if (parsedValue < 0) {
23
- throw new Error('Invalid timeout: must be a positive number.');
24
- }
25
- return parsedValue;
26
- }, DEFAULT_TIMEOUT)
27
- .option('--save-local', 'Detect and save local edits before enqueuing translations', false)
28
- .option('--publish', 'Publish translations to the CDN', false)
29
- .option('--experimental-localize-static-urls', 'Triggering this will run a script after the cli tool that localizes all urls in content files. Currently only supported for md and mdx files.', false)
30
- .option('--experimental-hide-default-locale', 'When localizing static locales, hide the default locale from the path', false)
31
- .option('--experimental-flatten-json-files', 'Triggering this will flatten the json files into a single file. This is useful for projects that have a lot of json files.', false)
32
- .option('--experimental-localize-static-imports', 'Triggering this will run a script after the cli tool that localizes all static imports in content files. Currently only supported for md and mdx files.', false)
33
- .option('--experimental-localize-relative-assets', 'Triggering this will rewrite relative image asset URLs in translated md/mdx files to valid paths.', false)
34
- .option('--force', 'Force a retranslation, invalidating all existing cached translations if they exist.', false)
35
- .option('--force-download', 'Force download and overwrite local files, bypassing gt-lock.json checks.', false)
36
- .option('--experimental-clear-locale-dirs', 'Clear locale directories before downloading new translations', false)
37
- .option('--branch <branch>', 'Specify a custom branch to use for translations')
38
- .option('--disable-branch-detection', 'Disable additional branch detection and optimizations and use the manually specified branch', false)
39
- .option('--enable-branching', 'Enable branching for the project')
40
- .option('--remote-name <name>', 'Specify a custom remote name to use for branch detection', DEFAULT_GIT_REMOTE_NAME);
41
- return command;
42
- }
43
- /**
44
- * Attaches flags necessary for parsing inline content
45
- * @param command - The command to attach the flags to
46
- * @returns The command with the inline content parsing flags attached
47
- */
48
- function attachInlineContentParsingFlags(command) {
49
- return command
50
- .option('--tsconfig, --jsconfig <path>', 'Path to custom jsconfig or tsconfig file', findFilepath(['./tsconfig.json', './jsconfig.json']))
51
- .option('--dictionary <path>', 'Path to dictionary file')
52
- .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}'")
53
- .option('--inline', 'Include inline content in translations (e.g., inline jsx translations, inline string translations, etc.)', true);
54
- }
55
- /**
56
- * Attaches flags necessary for validating a project
57
- * @param command
58
- * @returns The command with the validate flags attached
59
- */
60
- export function attachValidateFlags(command) {
61
- return attachInlineContentParsingFlags(command.option('-c, --config <path>', 'Filepath to config file, by default gt.config.json', findFilepath(['gt.config.json'])));
62
- }
63
- /**
64
- * Attaches flags necessary for translating a project
65
- * @param command
66
- * @returns The command with the translate flags attached
67
- */
68
- export function attachInlineTranslateFlags(command) {
69
- return attachInlineContentParsingFlags(command.option('--ignore-errors', 'Ignore errors encountered while scanning for inline content', false));
70
- }
@@ -1,17 +0,0 @@
1
- import { Command } from 'commander';
2
- import { BaseCLI } from './base.js';
3
- import { SupportedLibraries, TranslateFlags, Options } from '../types/index.js';
4
- import { InlineLibrary } from '../types/libraries.js';
5
- /**
6
- * Stand in for a CLI tool that does any sort of inline content translations
7
- */
8
- export declare class InlineCLI extends BaseCLI {
9
- constructor(command: Command, library: InlineLibrary, additionalModules?: SupportedLibraries[]);
10
- init(): void;
11
- protected setupStageCommand(): void;
12
- protected setupTranslateCommand(): void;
13
- protected setupValidateCommand(): void;
14
- protected setupGenerateSourceCommand(): void;
15
- protected handleGenerateSourceCommand(initOptions: TranslateFlags): Promise<void>;
16
- protected handleValidate(initOptions: Options, files?: string[]): Promise<void>;
17
- }
@@ -1,135 +0,0 @@
1
- import { BaseCLI } from './base.js';
2
- import { attachInlineTranslateFlags, attachTranslateFlags, attachValidateFlags, } from './flags.js';
3
- import { displayHeader, exitSync } from '../console/logging.js';
4
- import { logger } from '../console/logger.js';
5
- import { intro } from '@clack/prompts';
6
- import chalk from 'chalk';
7
- import { resolveLocaleFiles } from '../fs/config/parseFilesConfig.js';
8
- import { noFilesError } from '../console/index.js';
9
- import { saveJSON } from '../fs/saveJSON.js';
10
- import loadJSON from '../fs/loadJSON.js';
11
- import { generateSettings } from '../config/generateSettings.js';
12
- import { aggregateInlineTranslations } from '../translation/stage.js';
13
- import { validateConfigExists } from '../config/validateSettings.js';
14
- import { validateProject } from '../translation/validate.js';
15
- import { Libraries } from '../types/libraries.js';
16
- /**
17
- * Stand in for a CLI tool that does any sort of inline content translations
18
- */
19
- export class InlineCLI extends BaseCLI {
20
- constructor(command, library, additionalModules) {
21
- super(command, library, additionalModules);
22
- }
23
- init() {
24
- this.setupStageCommand();
25
- this.setupTranslateCommand();
26
- this.setupGenerateSourceCommand();
27
- this.setupValidateCommand();
28
- this.setupDownloadCommand();
29
- this.setupEnqueueCommand();
30
- }
31
- setupStageCommand() {
32
- attachInlineTranslateFlags(attachTranslateFlags(this.program
33
- .command('stage')
34
- .description('Submits the project to the General Translation API for translation. Translations created using this command will require human approval.'))).action(async (options) => {
35
- displayHeader('Staging project for translation with approval required...');
36
- await this.handleStage(options);
37
- logger.endCommand('Done!');
38
- });
39
- }
40
- setupTranslateCommand() {
41
- attachInlineTranslateFlags(attachTranslateFlags(this.program
42
- .command('translate')
43
- .description('Scans the project for a dictionary and inline translations and sends the updates to the General Translation API for translation.'))).action(async (options) => {
44
- displayHeader('Translating project...');
45
- await this.handleTranslate(options);
46
- logger.endCommand('Done!');
47
- });
48
- }
49
- setupValidateCommand() {
50
- attachValidateFlags(this.program
51
- .command('validate [files...]')
52
- .description('Scans the project for a dictionary and/or inline content and validates the project for errors.')).action(async (files, options) => {
53
- // intro here since we don't want to show the ascii title
54
- intro(chalk.cyan('Validating project...'));
55
- await this.handleValidate(options, files);
56
- logger.endCommand('Done!');
57
- });
58
- }
59
- setupGenerateSourceCommand() {
60
- attachInlineTranslateFlags(attachTranslateFlags(this.program
61
- .command('generate')
62
- .description('Generate a translation file for the source locale. This command should be used if you are handling your own translations.'))).action(async (initOptions) => {
63
- displayHeader('Generating source templates...');
64
- await this.handleGenerateSourceCommand(initOptions);
65
- logger.endCommand('Done!');
66
- });
67
- }
68
- async handleGenerateSourceCommand(initOptions) {
69
- const settings = await generateSettings(initOptions);
70
- const updates = await aggregateInlineTranslations(initOptions, settings, fallbackToGtReact(this.library));
71
- // Convert updates to the proper data format
72
- const newData = {};
73
- for (const update of updates) {
74
- const { source, metadata } = update;
75
- const { hash, id } = metadata;
76
- if (id) {
77
- newData[id] = source;
78
- }
79
- else {
80
- newData[hash] = source;
81
- }
82
- }
83
- // Save source file if files.json is provided
84
- if (settings.files && settings.files.placeholderPaths.gt) {
85
- const translationFiles = resolveLocaleFiles(settings.files.placeholderPaths, settings.defaultLocale);
86
- if (!translationFiles.gt) {
87
- logger.error(noFilesError);
88
- exitSync(1);
89
- }
90
- await saveJSON(translationFiles.gt, newData);
91
- logger.step('Source file saved successfully!');
92
- // Also save translations (after merging with existing translations)
93
- for (const locale of settings.locales) {
94
- const translationsFile = resolveLocaleFiles(settings.files.placeholderPaths, locale);
95
- if (!translationsFile.gt) {
96
- continue;
97
- }
98
- const existingTranslations = loadJSON(translationsFile.gt);
99
- const mergedTranslations = {
100
- ...newData,
101
- ...existingTranslations,
102
- };
103
- // Filter out keys that don't exist in newData
104
- const filteredTranslations = Object.fromEntries(Object.entries(mergedTranslations).filter(([key]) => newData[key]));
105
- await saveJSON(translationsFile.gt, filteredTranslations);
106
- }
107
- logger.step('Merged translations successfully!');
108
- }
109
- }
110
- async handleValidate(initOptions, files) {
111
- validateConfigExists();
112
- const settings = await generateSettings(initOptions);
113
- // First run the base class's handleTranslate method
114
- const options = { ...initOptions, ...settings };
115
- // Fallback to gt-react
116
- const pkg = fallbackToGtReact(this.library);
117
- if (files && files.length > 0) {
118
- // Validate specific files using createInlineUpdates
119
- await validateProject(options, pkg, files);
120
- }
121
- else {
122
- // Validate whole project as before
123
- await validateProject(options, pkg);
124
- }
125
- }
126
- }
127
- function fallbackToGtReact(library) {
128
- return [
129
- Libraries.GT_NEXT,
130
- Libraries.GT_NODE,
131
- Libraries.GT_REACT_NATIVE,
132
- ].includes(library)
133
- ? library
134
- : Libraries.GT_REACT;
135
- }
@@ -1,10 +0,0 @@
1
- import { WrapOptions, SupportedFrameworks, SupportedLibraries } from '../types/index.js';
2
- import { ReactCLI } from './react.js';
3
- import { Command } from 'commander';
4
- import { Libraries } from '../types/libraries.js';
5
- export declare class NextCLI extends ReactCLI {
6
- constructor(command: Command, library: typeof Libraries.GT_NEXT, additionalModules?: SupportedLibraries[]);
7
- protected wrapContent(options: WrapOptions, framework: SupportedFrameworks, errors: string[], warnings: string[]): Promise<{
8
- filesUpdated: string[];
9
- }>;
10
- }