gtx-cli 2.6.29 → 2.6.30-alpha.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 (340) hide show
  1. package/README.md +12 -3
  2. package/dist/bin/bin-entry.js +2 -1
  3. package/dist/functions.d.ts +1 -7
  4. package/dist/functions.js +1 -6
  5. package/dist/index.d.ts +1 -4
  6. package/dist/index.js +1 -27
  7. package/dist/main.js +2 -2
  8. package/package.json +9 -60
  9. package/CHANGELOG.md +0 -1255
  10. package/dist/api/collectUserEditDiffs.d.ts +0 -9
  11. package/dist/api/collectUserEditDiffs.js +0 -159
  12. package/dist/api/downloadFileBatch.d.ts +0 -23
  13. package/dist/api/downloadFileBatch.js +0 -190
  14. package/dist/api/saveLocalEdits.d.ts +0 -6
  15. package/dist/api/saveLocalEdits.js +0 -38
  16. package/dist/cli/base.d.ts +0 -59
  17. package/dist/cli/base.js +0 -529
  18. package/dist/cli/commands/download.d.ts +0 -8
  19. package/dist/cli/commands/download.js +0 -51
  20. package/dist/cli/commands/enqueue.d.ts +0 -9
  21. package/dist/cli/commands/enqueue.js +0 -27
  22. package/dist/cli/commands/setupProject.d.ts +0 -7
  23. package/dist/cli/commands/setupProject.js +0 -37
  24. package/dist/cli/commands/stage.d.ts +0 -9
  25. package/dist/cli/commands/stage.js +0 -59
  26. package/dist/cli/commands/translate.d.ts +0 -7
  27. package/dist/cli/commands/translate.js +0 -70
  28. package/dist/cli/commands/upload.d.ts +0 -13
  29. package/dist/cli/commands/upload.js +0 -142
  30. package/dist/cli/commands/utils/validation.d.ts +0 -13
  31. package/dist/cli/commands/utils/validation.js +0 -38
  32. package/dist/cli/flags.d.ts +0 -15
  33. package/dist/cli/flags.js +0 -70
  34. package/dist/cli/inline.d.ts +0 -17
  35. package/dist/cli/inline.js +0 -135
  36. package/dist/cli/next.d.ts +0 -10
  37. package/dist/cli/next.js +0 -12
  38. package/dist/cli/node.d.ts +0 -10
  39. package/dist/cli/node.js +0 -9
  40. package/dist/cli/react.d.ts +0 -12
  41. package/dist/cli/react.js +0 -72
  42. package/dist/config/generateSettings.d.ts +0 -9
  43. package/dist/config/generateSettings.js +0 -214
  44. package/dist/config/optionPresets.d.ts +0 -3
  45. package/dist/config/optionPresets.js +0 -65
  46. package/dist/config/resolveConfig.d.ts +0 -4
  47. package/dist/config/resolveConfig.js +0 -33
  48. package/dist/config/utils.d.ts +0 -2
  49. package/dist/config/utils.js +0 -4
  50. package/dist/config/validateSettings.d.ts +0 -3
  51. package/dist/config/validateSettings.js +0 -32
  52. package/dist/console/colors.d.ts +0 -6
  53. package/dist/console/colors.js +0 -19
  54. package/dist/console/displayTranslateSummary.d.ts +0 -1
  55. package/dist/console/displayTranslateSummary.js +0 -42
  56. package/dist/console/formatting.d.ts +0 -1
  57. package/dist/console/formatting.js +0 -7
  58. package/dist/console/index.d.ts +0 -33
  59. package/dist/console/index.js +0 -44
  60. package/dist/console/logger.d.ts +0 -35
  61. package/dist/console/logger.js +0 -250
  62. package/dist/console/logging.d.ts +0 -52
  63. package/dist/console/logging.js +0 -175
  64. package/dist/formats/files/aggregateFiles.d.ts +0 -4
  65. package/dist/formats/files/aggregateFiles.js +0 -173
  66. package/dist/formats/files/collectFiles.d.ts +0 -6
  67. package/dist/formats/files/collectFiles.js +0 -49
  68. package/dist/formats/files/convertToFileTranslationData.d.ts +0 -15
  69. package/dist/formats/files/convertToFileTranslationData.js +0 -21
  70. package/dist/formats/files/fileMapping.d.ts +0 -11
  71. package/dist/formats/files/fileMapping.js +0 -115
  72. package/dist/formats/files/save.d.ts +0 -5
  73. package/dist/formats/files/save.js +0 -17
  74. package/dist/formats/files/supportedFiles.d.ts +0 -11
  75. package/dist/formats/files/supportedFiles.js +0 -20
  76. package/dist/formats/json/extractJson.d.ts +0 -15
  77. package/dist/formats/json/extractJson.js +0 -101
  78. package/dist/formats/json/flattenJson.d.ts +0 -14
  79. package/dist/formats/json/flattenJson.js +0 -64
  80. package/dist/formats/json/mergeJson.d.ts +0 -13
  81. package/dist/formats/json/mergeJson.js +0 -367
  82. package/dist/formats/json/parseJson.d.ts +0 -2
  83. package/dist/formats/json/parseJson.js +0 -109
  84. package/dist/formats/json/utils.d.ts +0 -47
  85. package/dist/formats/json/utils.js +0 -150
  86. package/dist/formats/utils.d.ts +0 -2
  87. package/dist/formats/utils.js +0 -24
  88. package/dist/formats/yaml/mergeYaml.d.ts +0 -5
  89. package/dist/formats/yaml/mergeYaml.js +0 -61
  90. package/dist/formats/yaml/parseYaml.d.ts +0 -5
  91. package/dist/formats/yaml/parseYaml.js +0 -24
  92. package/dist/formats/yaml/utils.d.ts +0 -2
  93. package/dist/formats/yaml/utils.js +0 -23
  94. package/dist/fs/clearLocaleDirs.d.ts +0 -8
  95. package/dist/fs/clearLocaleDirs.js +0 -126
  96. package/dist/fs/config/downloadedVersions.d.ts +0 -21
  97. package/dist/fs/config/downloadedVersions.js +0 -50
  98. package/dist/fs/config/loadConfig.d.ts +0 -1
  99. package/dist/fs/config/loadConfig.js +0 -9
  100. package/dist/fs/config/parseFilesConfig.d.ts +0 -27
  101. package/dist/fs/config/parseFilesConfig.js +0 -150
  102. package/dist/fs/config/setupConfig.d.ts +0 -17
  103. package/dist/fs/config/setupConfig.js +0 -50
  104. package/dist/fs/config/updateConfig.d.ts +0 -21
  105. package/dist/fs/config/updateConfig.js +0 -57
  106. package/dist/fs/config/updateVersions.d.ts +0 -11
  107. package/dist/fs/config/updateVersions.js +0 -30
  108. package/dist/fs/copyFile.d.ts +0 -7
  109. package/dist/fs/copyFile.js +0 -39
  110. package/dist/fs/createLoadTranslationsFile.d.ts +0 -1
  111. package/dist/fs/createLoadTranslationsFile.js +0 -49
  112. package/dist/fs/determineFramework.d.ts +0 -5
  113. package/dist/fs/determineFramework.js +0 -53
  114. package/dist/fs/findFilepath.d.ts +0 -36
  115. package/dist/fs/findFilepath.js +0 -90
  116. package/dist/fs/index.d.ts +0 -1
  117. package/dist/fs/index.js +0 -1
  118. package/dist/fs/loadJSON.d.ts +0 -6
  119. package/dist/fs/loadJSON.js +0 -17
  120. package/dist/fs/matchFiles.d.ts +0 -1
  121. package/dist/fs/matchFiles.js +0 -8
  122. package/dist/fs/saveJSON.d.ts +0 -1
  123. package/dist/fs/saveJSON.js +0 -7
  124. package/dist/fs/utils.d.ts +0 -1
  125. package/dist/fs/utils.js +0 -16
  126. package/dist/generated/version.d.ts +0 -1
  127. package/dist/generated/version.js +0 -2
  128. package/dist/git/branches.d.ts +0 -7
  129. package/dist/git/branches.js +0 -88
  130. package/dist/hooks/postProcess.d.ts +0 -4
  131. package/dist/hooks/postProcess.js +0 -110
  132. package/dist/locadex/setupFlow.d.ts +0 -2
  133. package/dist/locadex/setupFlow.js +0 -9
  134. package/dist/next/config/parseNextConfig.d.ts +0 -10
  135. package/dist/next/config/parseNextConfig.js +0 -53
  136. package/dist/next/jsx/utils.d.ts +0 -7
  137. package/dist/next/jsx/utils.js +0 -42
  138. package/dist/next/parse/handleInitGT.d.ts +0 -7
  139. package/dist/next/parse/handleInitGT.js +0 -157
  140. package/dist/next/parse/wrapContent.d.ts +0 -12
  141. package/dist/next/parse/wrapContent.js +0 -164
  142. package/dist/react/config/createESBuildConfig.d.ts +0 -2
  143. package/dist/react/config/createESBuildConfig.js +0 -119
  144. package/dist/react/jsx/evaluateJsx.d.ts +0 -24
  145. package/dist/react/jsx/evaluateJsx.js +0 -123
  146. package/dist/react/jsx/utils/buildImportMap.d.ts +0 -9
  147. package/dist/react/jsx/utils/buildImportMap.js +0 -30
  148. package/dist/react/jsx/utils/constants.d.ts +0 -13
  149. package/dist/react/jsx/utils/constants.js +0 -46
  150. package/dist/react/jsx/utils/getCalleeNameFromExpression.d.ts +0 -9
  151. package/dist/react/jsx/utils/getCalleeNameFromExpression.js +0 -32
  152. package/dist/react/jsx/utils/getPathsAndAliases.d.ts +0 -21
  153. package/dist/react/jsx/utils/getPathsAndAliases.js +0 -91
  154. package/dist/react/jsx/utils/isNumberLiteral.d.ts +0 -7
  155. package/dist/react/jsx/utils/isNumberLiteral.js +0 -13
  156. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.d.ts +0 -9
  157. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +0 -135
  158. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.d.ts +0 -6
  159. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +0 -197
  160. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.d.ts +0 -13
  161. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +0 -42
  162. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.d.ts +0 -5
  163. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +0 -69
  164. package/dist/react/jsx/utils/jsxParsing/parseJsx.d.ts +0 -33
  165. package/dist/react/jsx/utils/jsxParsing/parseJsx.js +0 -912
  166. package/dist/react/jsx/utils/jsxParsing/parseTProps.d.ts +0 -8
  167. package/dist/react/jsx/utils/jsxParsing/parseTProps.js +0 -65
  168. package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.d.ts +0 -2
  169. package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +0 -61
  170. package/dist/react/jsx/utils/jsxParsing/types.d.ts +0 -48
  171. package/dist/react/jsx/utils/jsxParsing/types.js +0 -34
  172. package/dist/react/jsx/utils/mapAttributeName.d.ts +0 -11
  173. package/dist/react/jsx/utils/mapAttributeName.js +0 -12
  174. package/dist/react/jsx/utils/parseAst.d.ts +0 -31
  175. package/dist/react/jsx/utils/parseAst.js +0 -278
  176. package/dist/react/jsx/utils/parseDeclareStatic.d.ts +0 -15
  177. package/dist/react/jsx/utils/parseDeclareStatic.js +0 -540
  178. package/dist/react/jsx/utils/parseString.d.ts +0 -25
  179. package/dist/react/jsx/utils/parseString.js +0 -540
  180. package/dist/react/jsx/utils/parseStringFunction.d.ts +0 -30
  181. package/dist/react/jsx/utils/parseStringFunction.js +0 -348
  182. package/dist/react/jsx/utils/resolveImportPath.d.ts +0 -11
  183. package/dist/react/jsx/utils/resolveImportPath.js +0 -111
  184. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.d.ts +0 -29
  185. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +0 -86
  186. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.d.ts +0 -14
  187. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +0 -24
  188. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.d.ts +0 -19
  189. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +0 -31
  190. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.d.ts +0 -22
  191. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.js +0 -51
  192. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.d.ts +0 -18
  193. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +0 -39
  194. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.d.ts +0 -24
  195. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +0 -68
  196. package/dist/react/jsx/utils/stringParsing/types.d.ts +0 -41
  197. package/dist/react/jsx/utils/stringParsing/types.js +0 -1
  198. package/dist/react/jsx/utils/types.d.ts +0 -14
  199. package/dist/react/jsx/utils/types.js +0 -1
  200. package/dist/react/jsx/utils/validateStringFunction.d.ts +0 -7
  201. package/dist/react/jsx/utils/validateStringFunction.js +0 -31
  202. package/dist/react/jsx/wrapJsx.d.ts +0 -51
  203. package/dist/react/jsx/wrapJsx.js +0 -387
  204. package/dist/react/parse/addVitePlugin/index.d.ts +0 -22
  205. package/dist/react/parse/addVitePlugin/index.js +0 -41
  206. package/dist/react/parse/addVitePlugin/installCompiler.d.ts +0 -8
  207. package/dist/react/parse/addVitePlugin/installCompiler.js +0 -22
  208. package/dist/react/parse/addVitePlugin/updateViteConfig.d.ts +0 -19
  209. package/dist/react/parse/addVitePlugin/updateViteConfig.js +0 -120
  210. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.d.ts +0 -9
  211. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +0 -34
  212. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.d.ts +0 -11
  213. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +0 -48
  214. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.d.ts +0 -15
  215. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +0 -113
  216. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.d.ts +0 -12
  217. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +0 -32
  218. package/dist/react/parse/createDictionaryUpdates.d.ts +0 -3
  219. package/dist/react/parse/createDictionaryUpdates.js +0 -187
  220. package/dist/react/parse/createInlineUpdates.d.ts +0 -13
  221. package/dist/react/parse/createInlineUpdates.js +0 -161
  222. package/dist/react/parse/wrapContent.d.ts +0 -12
  223. package/dist/react/parse/wrapContent.js +0 -162
  224. package/dist/react/utils/flattenDictionary.d.ts +0 -20
  225. package/dist/react/utils/flattenDictionary.js +0 -75
  226. package/dist/react/utils/getEntryAndMetadata.d.ts +0 -5
  227. package/dist/react/utils/getEntryAndMetadata.js +0 -11
  228. package/dist/react/utils/getVariableName.d.ts +0 -25
  229. package/dist/react/utils/getVariableName.js +0 -37
  230. package/dist/setup/agentInstructions.d.ts +0 -24
  231. package/dist/setup/agentInstructions.js +0 -138
  232. package/dist/setup/detectFramework.d.ts +0 -31
  233. package/dist/setup/detectFramework.js +0 -106
  234. package/dist/setup/frameworkUtils.d.ts +0 -3
  235. package/dist/setup/frameworkUtils.js +0 -30
  236. package/dist/setup/instructions/base.md +0 -29
  237. package/dist/setup/instructions/gt-next.md +0 -107
  238. package/dist/setup/instructions/gt-react.md +0 -98
  239. package/dist/setup/userInput.d.ts +0 -4
  240. package/dist/setup/userInput.js +0 -32
  241. package/dist/setup/wizard.d.ts +0 -3
  242. package/dist/setup/wizard.js +0 -147
  243. package/dist/state/recentDownloads.d.ts +0 -12
  244. package/dist/state/recentDownloads.js +0 -18
  245. package/dist/state/translateWarnings.d.ts +0 -10
  246. package/dist/state/translateWarnings.js +0 -13
  247. package/dist/translation/parse.d.ts +0 -17
  248. package/dist/translation/parse.js +0 -77
  249. package/dist/translation/stage.d.ts +0 -3
  250. package/dist/translation/stage.js +0 -44
  251. package/dist/translation/validate.d.ts +0 -14
  252. package/dist/translation/validate.js +0 -100
  253. package/dist/types/branch.d.ts +0 -14
  254. package/dist/types/branch.js +0 -1
  255. package/dist/types/data/json.d.ts +0 -6
  256. package/dist/types/data/json.js +0 -1
  257. package/dist/types/data.d.ts +0 -37
  258. package/dist/types/data.js +0 -1
  259. package/dist/types/files.d.ts +0 -8
  260. package/dist/types/files.js +0 -1
  261. package/dist/types/index.d.ts +0 -243
  262. package/dist/types/index.js +0 -1
  263. package/dist/types/libraries.d.ts +0 -31
  264. package/dist/types/libraries.js +0 -72
  265. package/dist/types/parsing.d.ts +0 -3
  266. package/dist/types/parsing.js +0 -1
  267. package/dist/utils/addExplicitAnchorIds.d.ts +0 -24
  268. package/dist/utils/addExplicitAnchorIds.js +0 -416
  269. package/dist/utils/constants.d.ts +0 -5
  270. package/dist/utils/constants.js +0 -6
  271. package/dist/utils/credentials.d.ts +0 -12
  272. package/dist/utils/credentials.js +0 -120
  273. package/dist/utils/flattenJsonFiles.d.ts +0 -2
  274. package/dist/utils/flattenJsonFiles.js +0 -36
  275. package/dist/utils/gitDiff.d.ts +0 -8
  276. package/dist/utils/gitDiff.js +0 -34
  277. package/dist/utils/gt.d.ts +0 -2
  278. package/dist/utils/gt.js +0 -2
  279. package/dist/utils/hash.d.ts +0 -6
  280. package/dist/utils/hash.js +0 -11
  281. package/dist/utils/headers.d.ts +0 -1
  282. package/dist/utils/headers.js +0 -14
  283. package/dist/utils/installPackage.d.ts +0 -3
  284. package/dist/utils/installPackage.js +0 -77
  285. package/dist/utils/localizeRelativeAssets.d.ts +0 -8
  286. package/dist/utils/localizeRelativeAssets.js +0 -166
  287. package/dist/utils/localizeStaticImports.d.ts +0 -15
  288. package/dist/utils/localizeStaticImports.js +0 -397
  289. package/dist/utils/localizeStaticUrls.d.ts +0 -19
  290. package/dist/utils/localizeStaticUrls.js +0 -450
  291. package/dist/utils/mintlifyTitleFallback.d.ts +0 -6
  292. package/dist/utils/mintlifyTitleFallback.js +0 -80
  293. package/dist/utils/packageInfo.d.ts +0 -3
  294. package/dist/utils/packageInfo.js +0 -17
  295. package/dist/utils/packageJson.d.ts +0 -6
  296. package/dist/utils/packageJson.js +0 -68
  297. package/dist/utils/packageManager.d.ts +0 -28
  298. package/dist/utils/packageManager.js +0 -269
  299. package/dist/utils/parse/needsCJS.d.ts +0 -20
  300. package/dist/utils/parse/needsCJS.js +0 -72
  301. package/dist/utils/persistPostprocessHashes.d.ts +0 -12
  302. package/dist/utils/persistPostprocessHashes.js +0 -39
  303. package/dist/utils/processAnchorIds.d.ts +0 -6
  304. package/dist/utils/processAnchorIds.js +0 -56
  305. package/dist/utils/processOpenApi.d.ts +0 -8
  306. package/dist/utils/processOpenApi.js +0 -651
  307. package/dist/utils/sanitizeFileContent.d.ts +0 -6
  308. package/dist/utils/sanitizeFileContent.js +0 -29
  309. package/dist/utils/sharedStaticAssets.d.ts +0 -9
  310. package/dist/utils/sharedStaticAssets.js +0 -384
  311. package/dist/utils/validateMdx.d.ts +0 -10
  312. package/dist/utils/validateMdx.js +0 -25
  313. package/dist/workflows/download.d.ts +0 -32
  314. package/dist/workflows/download.js +0 -127
  315. package/dist/workflows/enqueue.d.ts +0 -17
  316. package/dist/workflows/enqueue.js +0 -59
  317. package/dist/workflows/setupProject.d.ts +0 -13
  318. package/dist/workflows/setupProject.js +0 -48
  319. package/dist/workflows/stage.d.ts +0 -18
  320. package/dist/workflows/stage.js +0 -59
  321. package/dist/workflows/steps/BranchStep.d.ts +0 -13
  322. package/dist/workflows/steps/BranchStep.js +0 -161
  323. package/dist/workflows/steps/DownloadStep.d.ts +0 -19
  324. package/dist/workflows/steps/DownloadStep.js +0 -131
  325. package/dist/workflows/steps/EnqueueStep.d.ts +0 -15
  326. package/dist/workflows/steps/EnqueueStep.js +0 -33
  327. package/dist/workflows/steps/PollJobsStep.d.ts +0 -31
  328. package/dist/workflows/steps/PollJobsStep.js +0 -288
  329. package/dist/workflows/steps/SetupStep.d.ts +0 -16
  330. package/dist/workflows/steps/SetupStep.js +0 -72
  331. package/dist/workflows/steps/UploadSourcesStep.d.ts +0 -27
  332. package/dist/workflows/steps/UploadSourcesStep.js +0 -131
  333. package/dist/workflows/steps/UploadTranslationsStep.d.ts +0 -22
  334. package/dist/workflows/steps/UploadTranslationsStep.js +0 -71
  335. package/dist/workflows/steps/UserEditDiffsStep.d.ts +0 -11
  336. package/dist/workflows/steps/UserEditDiffsStep.js +0 -30
  337. package/dist/workflows/steps/WorkflowStep.d.ts +0 -4
  338. package/dist/workflows/steps/WorkflowStep.js +0 -2
  339. package/dist/workflows/upload.d.ts +0 -15
  340. package/dist/workflows/upload.js +0 -47
@@ -1,150 +0,0 @@
1
- import { getLocaleProperties } from 'generaltranslation';
2
- import { exitSync } from '../../console/logging.js';
3
- import { logger } from '../../console/logger.js';
4
- import { JSONPath } from 'jsonpath-plus';
5
- import { flattenJson } from './flattenJson.js';
6
- import path from 'node:path';
7
- import micromatch from 'micromatch';
8
- const { isMatch } = micromatch;
9
- // Find the matching source item in an array
10
- // where the key matches the identifying locale property
11
- // If no matching item is found, exit with an error
12
- export function findMatchingItemArray(locale, sourceObjectOptions, sourceObjectPointer, sourceObjectValue) {
13
- const { identifyingLocaleProperty, localeKeyJsonPath } = getSourceObjectOptionsArray(locale, sourceObjectPointer, sourceObjectOptions);
14
- // Use the json pointer key to locate the source item
15
- const matchingItems = {};
16
- for (const [index, item] of sourceObjectValue.entries()) {
17
- // Get the key candidates
18
- const keyCandidates = JSONPath({
19
- json: item,
20
- path: localeKeyJsonPath,
21
- resultType: 'all',
22
- flatten: true,
23
- wrap: true,
24
- });
25
- if (!keyCandidates) {
26
- logger.error(`Source item at path: ${sourceObjectPointer} does not have a key value at path: ${localeKeyJsonPath}`);
27
- return exitSync(1);
28
- }
29
- else if (keyCandidates.length === 0) {
30
- // If no key candidates, skip the item
31
- continue;
32
- }
33
- else if (keyCandidates.length > 1) {
34
- // If multiple key candidates, exit with an error
35
- logger.error(`Source item at path: ${sourceObjectPointer} has multiple matching keys with path: ${localeKeyJsonPath}`);
36
- return exitSync(1);
37
- }
38
- else if (identifyingLocaleProperty !== keyCandidates[0].value) {
39
- // Validate the key is the identifying locale property
40
- continue;
41
- }
42
- // Map the index to the source item
43
- matchingItems[`/${index}`] = {
44
- sourceItem: item,
45
- keyParentProperty: keyCandidates[0].parentProperty,
46
- keyPointer: keyCandidates[0].pointer,
47
- index,
48
- };
49
- }
50
- return matchingItems;
51
- }
52
- export function findMatchingItemObject(locale, sourceObjectPointer, sourceObjectOptions, sourceObjectValue) {
53
- const { identifyingLocaleProperty } = getSourceObjectOptionsObject(locale, sourceObjectPointer, sourceObjectOptions);
54
- // Locate the source item
55
- if (sourceObjectValue[identifyingLocaleProperty]) {
56
- return {
57
- sourceItem: sourceObjectValue[identifyingLocaleProperty],
58
- keyParentProperty: identifyingLocaleProperty,
59
- };
60
- }
61
- return {
62
- sourceItem: undefined,
63
- keyParentProperty: identifyingLocaleProperty,
64
- };
65
- }
66
- /**
67
- * Get the identifying locale property for an object
68
- * @param locale - The locale to get the identifying locale property for
69
- * @param sourceObjectPointer - The path to the source object
70
- * @param sourceObjectOptions - The source object options
71
- * @returns The identifying locale property
72
- */
73
- export function getIdentifyingLocaleProperty(locale, sourceObjectPointer, sourceObjectOptions) {
74
- // Validate localeProperty
75
- const localeProperty = sourceObjectOptions.localeProperty || 'code';
76
- const identifyingLocaleProperty = getLocaleProperties(locale)[localeProperty];
77
- if (!identifyingLocaleProperty) {
78
- logger.error(`Source object options localeProperty is not a valid locale property at path: ${sourceObjectPointer}`);
79
- return exitSync(1);
80
- }
81
- return identifyingLocaleProperty;
82
- }
83
- /**
84
- * Get the identifying locale property and the json path to the key for an array
85
- * @param locale - The locale to get the identifying locale property for
86
- * @param sourceObjectPointer - The path to the source object
87
- * @param sourceObjectOptions - The source object options
88
- * @returns The identifying locale property and the json path to the key
89
- */
90
- export function getSourceObjectOptionsArray(locale, sourceObjectPointer, sourceObjectOptions) {
91
- const identifyingLocaleProperty = getIdentifyingLocaleProperty(locale, sourceObjectPointer, sourceObjectOptions);
92
- const localeKeyJsonPath = sourceObjectOptions.key;
93
- if (!localeKeyJsonPath) {
94
- logger.error(`Source object options key is required for array at path: ${sourceObjectPointer}`);
95
- return exitSync(1);
96
- }
97
- return { identifyingLocaleProperty, localeKeyJsonPath };
98
- }
99
- export function getSourceObjectOptionsObject(defaultLocale, sourceObjectPointer, sourceObjectOptions) {
100
- const identifyingLocaleProperty = getIdentifyingLocaleProperty(defaultLocale, sourceObjectPointer, sourceObjectOptions);
101
- const jsonPathKey = sourceObjectOptions.key;
102
- if (jsonPathKey) {
103
- logger.error(`Source object options key is not allowed for object at path: ${sourceObjectPointer}`);
104
- return exitSync(1);
105
- }
106
- return { identifyingLocaleProperty };
107
- }
108
- /**
109
- * Generate a mapping of sourceObjectPointer to SourceObjectOptions
110
- * where the sourceObjectPointer is a jsonpointer to the array or object containing
111
- * @param jsonSchema - The json schema to generate the mapping from
112
- * @param originalJson - The original json to generate the mapping from
113
- * @returns A mapping of sourceObjectPointer to SourceObjectOptions
114
- */
115
- export function generateSourceObjectPointers(jsonSchema, originalJson) {
116
- const sourceObjectPointers = Object.entries(jsonSchema).reduce((acc, [sourceObjectPath, sourceObjectOptions]) => {
117
- const sourceObjects = flattenJson(originalJson, [sourceObjectPath]);
118
- Object.entries(sourceObjects).forEach(([pointer, value]) => {
119
- acc[pointer] = {
120
- sourceObjectValue: value,
121
- sourceObjectOptions,
122
- };
123
- });
124
- return acc;
125
- }, {});
126
- return sourceObjectPointers;
127
- }
128
- export function validateJsonSchema(options, filePath) {
129
- if (!options.jsonSchema) {
130
- return null;
131
- }
132
- const fileGlobs = Object.keys(options.jsonSchema);
133
- const matchingGlob = fileGlobs.find((fileGlob) => isMatch(path.relative(process.cwd(), filePath), fileGlob));
134
- if (!matchingGlob || !options.jsonSchema[matchingGlob]) {
135
- return null;
136
- }
137
- // Validate includes or composite
138
- const jsonSchema = options.jsonSchema[matchingGlob];
139
- if (jsonSchema.include && jsonSchema.composite) {
140
- logger.error('include and composite cannot be used together in the same JSON schema');
141
- return exitSync(1);
142
- return null;
143
- }
144
- if (!jsonSchema.include && !jsonSchema.composite) {
145
- logger.error('No include or composite property found in JSON schema');
146
- return exitSync(1);
147
- return null;
148
- }
149
- return jsonSchema;
150
- }
@@ -1,2 +0,0 @@
1
- import { LocaleProperties } from 'generaltranslation/types';
2
- export declare function replaceLocalePlaceholders(string: string, localeProperties: LocaleProperties): string;
@@ -1,24 +0,0 @@
1
- // helper function to replace locale placeholders in a string
2
- // with the corresponding locale properties
3
- // ex: {locale} -> will be replaced with the locale code
4
- // ex: {localeName} -> will be replaced with the locale name
5
- export function replaceLocalePlaceholders(string, localeProperties) {
6
- return string.replace(/\{(\w+)\}/g, (match, property) => {
7
- // Handle common aliases
8
- if (property === 'locale' || property === 'localeCode') {
9
- return localeProperties.code;
10
- }
11
- if (property === 'localeName') {
12
- return localeProperties.name;
13
- }
14
- if (property === 'localeNativeName') {
15
- return localeProperties.nativeName;
16
- }
17
- // Check if the property exists in localeProperties
18
- if (property in localeProperties) {
19
- return localeProperties[property];
20
- }
21
- // Return the original placeholder if property not found
22
- return match;
23
- });
24
- }
@@ -1,5 +0,0 @@
1
- import { AdditionalOptions } from '../../types/index.js';
2
- export default function mergeYaml(originalContent: string, inputPath: string, options: AdditionalOptions, targets: {
3
- translatedContent: string;
4
- targetLocale: string;
5
- }[], defaultLocale: string): string[];
@@ -1,61 +0,0 @@
1
- import JSONPointer from 'jsonpointer';
2
- import { exitSync } from '../../console/logging.js';
3
- import { logger } from '../../console/logger.js';
4
- import { validateYamlSchema } from './utils.js';
5
- import YAML from 'yaml';
6
- import { applyTransformations } from '../json/mergeJson.js';
7
- export default function mergeYaml(originalContent, inputPath, options, targets, defaultLocale) {
8
- const yamlSchema = validateYamlSchema(options, inputPath);
9
- if (!yamlSchema) {
10
- return targets.map((target) => target.translatedContent);
11
- }
12
- let originalYaml;
13
- try {
14
- originalYaml = YAML.parse(originalContent);
15
- }
16
- catch {
17
- logger.error(`Invalid YAML file: ${inputPath}`);
18
- return exitSync(1);
19
- }
20
- // Unreachable (validated in validateYamlSchema, included for type check)
21
- if (!yamlSchema.include) {
22
- logger.error('No include property found in YAML schema');
23
- return exitSync(1);
24
- }
25
- // Handle include
26
- const output = [];
27
- for (const target of targets) {
28
- // Must clone the original YAML to avoid mutations
29
- const mergedYaml = JSON.parse(JSON.stringify(originalYaml));
30
- let translatedJson;
31
- try {
32
- translatedJson = JSON.parse(target.translatedContent);
33
- }
34
- catch {
35
- // If parsing fails, treat as empty object to avoid crashes
36
- translatedJson = {};
37
- }
38
- for (const [jsonPointer, translatedValue] of Object.entries(translatedJson)) {
39
- try {
40
- // Try to get the value - if this succeeds, the pointer exists
41
- if (JSONPointer.get(mergedYaml, jsonPointer) == null) {
42
- continue;
43
- }
44
- // Set the new value regardless of what the current value is (including null/falsy)
45
- JSONPointer.set(mergedYaml, jsonPointer, translatedValue);
46
- }
47
- catch {
48
- // Silently ignore invalid or non-existent JSON pointers
49
- }
50
- }
51
- // Apply transformations if they exist
52
- if (yamlSchema.transform) {
53
- applyTransformations(mergedYaml, yamlSchema.transform, target.targetLocale, defaultLocale);
54
- }
55
- output.push(YAML.stringify(mergedYaml));
56
- }
57
- if (!output.length) {
58
- return [originalContent];
59
- }
60
- return output;
61
- }
@@ -1,5 +0,0 @@
1
- import { AdditionalOptions } from '../../types/index.js';
2
- export default function parseYaml(content: string, filePath: string, options: AdditionalOptions): {
3
- content: string;
4
- fileFormat: 'JSON' | 'YAML';
5
- };
@@ -1,24 +0,0 @@
1
- import { exitSync } from '../../console/logging.js';
2
- import { logger } from '../../console/logger.js';
3
- import YAML from 'yaml';
4
- import { validateYamlSchema } from './utils.js';
5
- import { flattenJsonWithStringFilter } from '../json/flattenJson.js';
6
- export default function parseYaml(content, filePath, options) {
7
- const yamlSchema = validateYamlSchema(options, filePath);
8
- if (!yamlSchema) {
9
- return { content, fileFormat: 'YAML' };
10
- }
11
- let yaml;
12
- try {
13
- yaml = YAML.parse(content);
14
- }
15
- catch {
16
- logger.error(`Invalid YAML file: ${filePath}`);
17
- return exitSync(1);
18
- }
19
- if (yamlSchema.include) {
20
- const flattenedYaml = flattenJsonWithStringFilter(yaml, yamlSchema.include);
21
- return { content: JSON.stringify(flattenedYaml), fileFormat: 'JSON' };
22
- }
23
- return { content, fileFormat: 'YAML' };
24
- }
@@ -1,2 +0,0 @@
1
- import { AdditionalOptions, YamlSchema } from '../../types/index.js';
2
- export declare function validateYamlSchema(options: AdditionalOptions, filePath: string): YamlSchema | null;
@@ -1,23 +0,0 @@
1
- import { exitSync } from '../../console/logging.js';
2
- import { logger } from '../../console/logger.js';
3
- import micromatch from 'micromatch';
4
- const { isMatch } = micromatch;
5
- import path from 'path';
6
- export function validateYamlSchema(options, filePath) {
7
- if (!options.yamlSchema) {
8
- return null;
9
- }
10
- // Check if the file matches any of the yaml schema globs
11
- const fileGlobs = Object.keys(options.yamlSchema);
12
- const matchingGlob = fileGlobs.find((fileGlob) => isMatch(path.relative(process.cwd(), filePath), fileGlob));
13
- if (!matchingGlob || !options.yamlSchema[matchingGlob]) {
14
- return null;
15
- }
16
- // Validate includes
17
- const yamlSchema = options.yamlSchema[matchingGlob];
18
- if (!yamlSchema.include) {
19
- logger.error('No include property found in YAML schema');
20
- return exitSync(1);
21
- }
22
- return yamlSchema;
23
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Clears translated files before writing new translations
3
- * @param filePaths - Set of translated file paths to clear
4
- * @param locales - Array of locale codes to match against
5
- * @param excludePatterns - Optional array of glob patterns to exclude from clearing (supports [locale] and [locales])
6
- * @param cwd - Current working directory for resolving relative exclude patterns (defaults to process.cwd())
7
- */
8
- export declare function clearLocaleDirs(filePaths: Set<string>, locales: string[], excludePatterns?: string[], cwd?: string): Promise<void>;
@@ -1,126 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'node:path';
3
- import { logger } from '../console/logger.js';
4
- import fg from 'fast-glob';
5
- import micromatch from 'micromatch';
6
- /**
7
- * Extracts locale directories from translated file paths.
8
- * Groups files by their immediate parent containing a locale code.
9
- * For example: "snippets/es/api-test/file.mdx" -> "snippets/es"
10
- */
11
- function extractLocaleDirectories(filePaths, locales) {
12
- const localeDirs = new Set();
13
- const localeSet = new Set(locales);
14
- for (const filePath of filePaths) {
15
- const parts = filePath.split(path.sep);
16
- // Find directory segments that match the provided locales
17
- for (let i = 0; i < parts.length - 1; i++) {
18
- const segment = parts[i];
19
- if (localeSet.has(segment)) {
20
- // Found a locale directory, capture up to and including this segment
21
- const localeDir = parts.slice(0, i + 1).join(path.sep);
22
- localeDirs.add(localeDir);
23
- break;
24
- }
25
- }
26
- }
27
- return localeDirs;
28
- }
29
- async function getAllFiles(dirPath) {
30
- return await fg(path.join(dirPath, '**/*'), {
31
- absolute: true,
32
- onlyFiles: true,
33
- });
34
- }
35
- async function getFilesToDelete(dirPath, excludePatterns, currentLocale, cwd) {
36
- const allFiles = await getAllFiles(dirPath);
37
- const absoluteCwd = path.resolve(cwd);
38
- const expandedExcludePatterns = excludePatterns.map((p) => {
39
- const resolvedPattern = path.isAbsolute(p) ? p : path.join(absoluteCwd, p);
40
- return resolvedPattern
41
- .replace(/\[locale\]/g, currentLocale)
42
- .replace(/\[locales\]/g, currentLocale);
43
- });
44
- const filesToKeep = micromatch(allFiles, expandedExcludePatterns, {
45
- dot: true,
46
- });
47
- const filesToKeepSet = new Set(filesToKeep);
48
- return allFiles.filter((file) => !filesToKeepSet.has(file));
49
- }
50
- /**
51
- * Clears translated files before writing new translations
52
- * @param filePaths - Set of translated file paths to clear
53
- * @param locales - Array of locale codes to match against
54
- * @param excludePatterns - Optional array of glob patterns to exclude from clearing (supports [locale] and [locales])
55
- * @param cwd - Current working directory for resolving relative exclude patterns (defaults to process.cwd())
56
- */
57
- export async function clearLocaleDirs(filePaths, locales, excludePatterns, cwd = process.cwd()) {
58
- // Extract locale directories
59
- const localeDirs = extractLocaleDirectories(filePaths, locales);
60
- for (const dir of localeDirs) {
61
- try {
62
- await fs.stat(dir);
63
- // Extract locale from directory path
64
- const dirParts = dir.split(path.sep);
65
- const locale = locales.find((loc) => dirParts.includes(loc));
66
- if (!locale) {
67
- continue;
68
- }
69
- if (!excludePatterns?.length) {
70
- await fs.rm(dir, { recursive: true, force: true });
71
- logger.success(`Cleared locale directory: ${dir}`);
72
- continue;
73
- }
74
- const filesToDelete = await getFilesToDelete(dir, excludePatterns, locale, cwd);
75
- // Get all files for count comparison
76
- const allFiles = await getAllFiles(dir);
77
- for (const file of filesToDelete) {
78
- try {
79
- await fs.unlink(file);
80
- }
81
- catch (error) {
82
- if (error.code !== 'ENOENT') {
83
- logger.warn(`Failed to delete file ${file}: ${error}`);
84
- }
85
- }
86
- }
87
- // Clean up empty directories
88
- await cleanupEmptyDirs(dir);
89
- const excludedCount = allFiles.length - filesToDelete.length;
90
- if (excludedCount > 0) {
91
- logger.success(`Cleared locale directory: ${dir} (excluded ${excludedCount} file${excludedCount > 1 ? 's' : ''})`);
92
- }
93
- else {
94
- logger.success(`Cleared locale directory: ${dir}`);
95
- }
96
- }
97
- catch (error) {
98
- if (error.code !== 'ENOENT') {
99
- logger.warn(`Failed to clear locale directory ${dir}: ${error}`);
100
- }
101
- }
102
- }
103
- }
104
- /**
105
- * Recursively removes empty directories
106
- * @param dirPath - The directory to clean up
107
- */
108
- async function cleanupEmptyDirs(dirPath) {
109
- try {
110
- const entries = await fs.readdir(dirPath, { withFileTypes: true });
111
- // Recursively clean subdirectories first
112
- for (const entry of entries) {
113
- if (entry.isDirectory()) {
114
- await cleanupEmptyDirs(path.join(dirPath, entry.name));
115
- }
116
- }
117
- // Check if directory is now empty
118
- const remainingEntries = await fs.readdir(dirPath);
119
- if (remainingEntries.length === 0) {
120
- await fs.rmdir(dirPath);
121
- }
122
- }
123
- catch (error) {
124
- // Ignore errors - directory might not exist or might not be empty
125
- }
126
- }
@@ -1,21 +0,0 @@
1
- export type DownloadedVersionEntry = {
2
- fileName?: string;
3
- updatedAt?: string;
4
- postProcessHash?: string;
5
- sourceHash?: string;
6
- };
7
- export type DownloadedVersions = {
8
- version: number;
9
- entries: {
10
- [branchId: string]: {
11
- [fileId: string]: {
12
- [versionId: string]: {
13
- [locale: string]: DownloadedVersionEntry;
14
- };
15
- };
16
- };
17
- };
18
- };
19
- export declare function getDownloadedVersions(configDirectory: string): DownloadedVersions;
20
- export declare function saveDownloadedVersions(configDirectory: string, lock: DownloadedVersions): void;
21
- export declare function ensureNestedObject(obj: any, path: string[]): any;
@@ -1,50 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { logger } from '../../console/logger.js';
4
- // New lock file name, use old name for deletion of legacy lock file
5
- const GT_LOCK_FILE = 'gt-lock.json';
6
- const LEGACY_DOWNLOADED_VERSIONS_FILE = 'downloaded-versions.json';
7
- export function getDownloadedVersions(configDirectory) {
8
- try {
9
- // Clean up legacy lock files inside the config directory
10
- const rootPath = path.join(process.cwd(), GT_LOCK_FILE);
11
- const legacyPath = path.join(configDirectory, LEGACY_DOWNLOADED_VERSIONS_FILE);
12
- try {
13
- if (fs.existsSync(legacyPath)) {
14
- fs.unlinkSync(legacyPath);
15
- }
16
- }
17
- catch { }
18
- const filepath = fs.existsSync(rootPath) ? rootPath : null;
19
- if (!filepath)
20
- return { version: 1, entries: {} };
21
- const raw = JSON.parse(fs.readFileSync(filepath, 'utf8'));
22
- if (raw && typeof raw === 'object' && raw.version && raw.entries) {
23
- return raw;
24
- }
25
- return { version: 1, entries: {} };
26
- }
27
- catch (error) {
28
- logger.error(`An error occurred while getting downloaded versions: ${error}`);
29
- return { version: 1, entries: {} };
30
- }
31
- }
32
- export function saveDownloadedVersions(configDirectory, lock) {
33
- try {
34
- // Write the lock file to the repo root
35
- const filepath = path.join(process.cwd(), GT_LOCK_FILE);
36
- fs.mkdirSync(path.dirname(filepath), { recursive: true });
37
- fs.writeFileSync(filepath, JSON.stringify(lock, null, 2));
38
- }
39
- catch (error) {
40
- logger.error(`An error occurred while updating ${GT_LOCK_FILE}: ${error}`);
41
- }
42
- }
43
- export function ensureNestedObject(obj, path) {
44
- return path.reduce((current, key, index) => {
45
- if (index === path.length - 1)
46
- return current;
47
- current[key] = current[key] || {};
48
- return current[key];
49
- }, obj);
50
- }
@@ -1 +0,0 @@
1
- export declare function loadConfig(filepath: string): Record<string, any>;
@@ -1,9 +0,0 @@
1
- import fs from 'node:fs';
2
- export function loadConfig(filepath) {
3
- try {
4
- return JSON.parse(fs.readFileSync(filepath, 'utf-8'));
5
- }
6
- catch (error) {
7
- return {};
8
- }
9
- }
@@ -1,27 +0,0 @@
1
- import { FilesOptions, ResolvedFiles, TransformFiles, TransformOption } from '../../types/index.js';
2
- /**
3
- * Resolves the files from the files object
4
- * Replaces [locale] with the actual locale in the files
5
- *
6
- * @param files - The files object
7
- * @param locale - The locale to replace [locale] with
8
- * @returns The resolved files
9
- */
10
- export declare function resolveLocaleFiles(files: ResolvedFiles, locale: string): ResolvedFiles;
11
- /**
12
- * Resolves the files from the files object
13
- * Performs glob pattern expansion on the files
14
- * Replaces [locale] with the actual locale in the files
15
- *
16
- * @param files - The files object
17
- * @returns The resolved files
18
- */
19
- export declare function resolveFiles(files: FilesOptions, locale: string, locales: string[], cwd: string, compositePatterns?: string[]): {
20
- resolvedPaths: ResolvedFiles;
21
- placeholderPaths: ResolvedFiles;
22
- transformPaths: TransformFiles;
23
- };
24
- export declare function expandGlobPatterns(cwd: string, includePatterns: string[], excludePatterns: string[], locale: string, locales: string[], transformPatterns?: TransformOption | string | TransformOption[], compositePatterns?: string[]): {
25
- resolvedPaths: string[];
26
- placeholderPaths: string[];
27
- };