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,86 +1,73 @@
1
- import { parse } from 'smol-toml';
2
- import { resolveGtDependency } from './resolveGtDependency.js';
1
+ import { resolveGtDependency } from "./resolveGtDependency.js";
2
+ import { parse } from "smol-toml";
3
+ //#region src/fs/determineFramework/matchPyprojectDependency.ts
3
4
  /**
4
- * Parse pyproject.toml for GT dependencies using a proper TOML parser.
5
- *
6
- * Checks the following locations:
7
- * - PEP 621: project.dependencies, project.optional-dependencies.*
8
- * - Poetry: tool.poetry.dependencies, tool.poetry.group.*.dependencies
9
- */
10
- export function matchPyprojectDependency(content) {
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- let parsed;
13
- try {
14
- parsed = parse(content);
15
- }
16
- catch {
17
- return null;
18
- }
19
- // 1. PEP 621: project.dependencies = ["gt-flask>=1.0", ...]
20
- const projectDeps = parsed?.project?.dependencies;
21
- if (Array.isArray(projectDeps)) {
22
- const result = matchDependencyArray(projectDeps);
23
- if (result)
24
- return result;
25
- }
26
- // 2. PEP 621: project.optional-dependencies.* = ["gt-flask", ...]
27
- const optDeps = parsed?.project?.['optional-dependencies'];
28
- if (optDeps && typeof optDeps === 'object') {
29
- for (const group of Object.values(optDeps)) {
30
- if (Array.isArray(group)) {
31
- const result = matchDependencyArray(group);
32
- if (result)
33
- return result;
34
- }
35
- }
36
- }
37
- // 3. Poetry: tool.poetry.dependencies = { gt-flask = "^1.0", ... }
38
- const poetryDeps = parsed?.tool?.poetry?.dependencies;
39
- if (poetryDeps && typeof poetryDeps === 'object') {
40
- const result = matchDependencyKeys(poetryDeps);
41
- if (result)
42
- return result;
43
- }
44
- // 4. Poetry groups: tool.poetry.group.*.dependencies
45
- const poetryGroups = parsed?.tool?.poetry?.group;
46
- if (poetryGroups && typeof poetryGroups === 'object') {
47
- for (const group of Object.values(poetryGroups)) {
48
- if (group && typeof group === 'object' && 'dependencies' in group) {
49
- const result = matchDependencyKeys(group.dependencies);
50
- if (result)
51
- return result;
52
- }
53
- }
54
- }
55
- return null;
5
+ * Parse pyproject.toml for GT dependencies using a proper TOML parser.
6
+ *
7
+ * Checks the following locations:
8
+ * - PEP 621: project.dependencies, project.optional-dependencies.*
9
+ * - Poetry: tool.poetry.dependencies, tool.poetry.group.*.dependencies
10
+ */
11
+ function matchPyprojectDependency(content) {
12
+ let parsed;
13
+ try {
14
+ parsed = parse(content);
15
+ } catch {
16
+ return null;
17
+ }
18
+ const projectDeps = parsed?.project?.dependencies;
19
+ if (Array.isArray(projectDeps)) {
20
+ const result = matchDependencyArray(projectDeps);
21
+ if (result) return result;
22
+ }
23
+ const optDeps = parsed?.project?.["optional-dependencies"];
24
+ if (optDeps && typeof optDeps === "object") {
25
+ for (const group of Object.values(optDeps)) if (Array.isArray(group)) {
26
+ const result = matchDependencyArray(group);
27
+ if (result) return result;
28
+ }
29
+ }
30
+ const poetryDeps = parsed?.tool?.poetry?.dependencies;
31
+ if (poetryDeps && typeof poetryDeps === "object") {
32
+ const result = matchDependencyKeys(poetryDeps);
33
+ if (result) return result;
34
+ }
35
+ const poetryGroups = parsed?.tool?.poetry?.group;
36
+ if (poetryGroups && typeof poetryGroups === "object") {
37
+ for (const group of Object.values(poetryGroups)) if (group && typeof group === "object" && "dependencies" in group) {
38
+ const result = matchDependencyKeys(group.dependencies);
39
+ if (result) return result;
40
+ }
41
+ }
42
+ return null;
56
43
  }
57
44
  /**
58
- * Check a PEP 508 dependency array (e.g. ["gt-flask>=1.0", "flask[extra]"])
59
- * for GT dependencies.
60
- */
45
+ * Check a PEP 508 dependency array (e.g. ["gt-flask>=1.0", "flask[extra]"])
46
+ * for GT dependencies.
47
+ */
61
48
  function matchDependencyArray(deps) {
62
- for (const dep of deps) {
63
- if (typeof dep !== 'string')
64
- continue;
65
- // Extract package name before version specifiers, extras, or markers
66
- const pkgName = dep.split(/[><=!~;@\s[]/)[0].trim();
67
- if (pkgName) {
68
- const result = resolveGtDependency(pkgName);
69
- if (result)
70
- return result;
71
- }
72
- }
73
- return null;
49
+ for (const dep of deps) {
50
+ if (typeof dep !== "string") continue;
51
+ const pkgName = dep.split(/[><=!~;@\s[]/)[0].trim();
52
+ if (pkgName) {
53
+ const result = resolveGtDependency(pkgName);
54
+ if (result) return result;
55
+ }
56
+ }
57
+ return null;
74
58
  }
75
59
  /**
76
- * Check Poetry-style dependency keys (e.g. { gt-flask = "^1.0" })
77
- * for GT dependencies.
78
- */
60
+ * Check Poetry-style dependency keys (e.g. { gt-flask = "^1.0" })
61
+ * for GT dependencies.
62
+ */
79
63
  function matchDependencyKeys(deps) {
80
- for (const key of Object.keys(deps)) {
81
- const result = resolveGtDependency(key);
82
- if (result)
83
- return result;
84
- }
85
- return null;
64
+ for (const key of Object.keys(deps)) {
65
+ const result = resolveGtDependency(key);
66
+ if (result) return result;
67
+ }
68
+ return null;
86
69
  }
70
+ //#endregion
71
+ export { matchPyprojectDependency };
72
+
73
+ //# sourceMappingURL=matchPyprojectDependency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchPyprojectDependency.js","names":[],"sources":["../../../src/fs/determineFramework/matchPyprojectDependency.ts"],"sourcesContent":["import { parse } from 'smol-toml';\nimport { Libraries } from '../../types/libraries.js';\nimport { resolveGtDependency } from './resolveGtDependency.js';\n\n/**\n * Parse pyproject.toml for GT dependencies using a proper TOML parser.\n *\n * Checks the following locations:\n * - PEP 621: project.dependencies, project.optional-dependencies.*\n * - Poetry: tool.poetry.dependencies, tool.poetry.group.*.dependencies\n */\nexport function matchPyprojectDependency(\n content: string\n): typeof Libraries.GT_FLASK | typeof Libraries.GT_FASTAPI | null {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let parsed: Record<string, any>;\n try {\n parsed = parse(content) as Record<string, unknown>;\n } catch {\n return null;\n }\n\n // 1. PEP 621: project.dependencies = [\"gt-flask>=1.0\", ...]\n const projectDeps = parsed?.project?.dependencies;\n if (Array.isArray(projectDeps)) {\n const result = matchDependencyArray(projectDeps);\n if (result) return result;\n }\n\n // 2. PEP 621: project.optional-dependencies.* = [\"gt-flask\", ...]\n const optDeps = parsed?.project?.['optional-dependencies'];\n if (optDeps && typeof optDeps === 'object') {\n for (const group of Object.values(optDeps)) {\n if (Array.isArray(group)) {\n const result = matchDependencyArray(group as string[]);\n if (result) return result;\n }\n }\n }\n\n // 3. Poetry: tool.poetry.dependencies = { gt-flask = \"^1.0\", ... }\n const poetryDeps = parsed?.tool?.poetry?.dependencies;\n if (poetryDeps && typeof poetryDeps === 'object') {\n const result = matchDependencyKeys(poetryDeps);\n if (result) return result;\n }\n\n // 4. Poetry groups: tool.poetry.group.*.dependencies\n const poetryGroups = parsed?.tool?.poetry?.group;\n if (poetryGroups && typeof poetryGroups === 'object') {\n for (const group of Object.values(poetryGroups)) {\n if (group && typeof group === 'object' && 'dependencies' in group) {\n const result = matchDependencyKeys(\n (group as Record<string, unknown>).dependencies as Record<\n string,\n unknown\n >\n );\n if (result) return result;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Check a PEP 508 dependency array (e.g. [\"gt-flask>=1.0\", \"flask[extra]\"])\n * for GT dependencies.\n */\nfunction matchDependencyArray(\n deps: string[]\n): typeof Libraries.GT_FLASK | typeof Libraries.GT_FASTAPI | null {\n for (const dep of deps) {\n if (typeof dep !== 'string') continue;\n // Extract package name before version specifiers, extras, or markers\n const pkgName = dep.split(/[><=!~;@\\s[]/)[0].trim();\n if (pkgName) {\n const result = resolveGtDependency(pkgName);\n if (result) return result;\n }\n }\n return null;\n}\n\n/**\n * Check Poetry-style dependency keys (e.g. { gt-flask = \"^1.0\" })\n * for GT dependencies.\n */\nfunction matchDependencyKeys(\n deps: Record<string, unknown>\n): typeof Libraries.GT_FLASK | typeof Libraries.GT_FASTAPI | null {\n for (const key of Object.keys(deps)) {\n const result = resolveGtDependency(key);\n if (result) return result;\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,yBACd,SACgE;CAEhE,IAAI;AACJ,KAAI;AACF,WAAS,MAAM,QAAQ;SACjB;AACN,SAAO;;CAIT,MAAM,cAAc,QAAQ,SAAS;AACrC,KAAI,MAAM,QAAQ,YAAY,EAAE;EAC9B,MAAM,SAAS,qBAAqB,YAAY;AAChD,MAAI,OAAQ,QAAO;;CAIrB,MAAM,UAAU,QAAQ,UAAU;AAClC,KAAI,WAAW,OAAO,YAAY;OAC3B,MAAM,SAAS,OAAO,OAAO,QAAQ,CACxC,KAAI,MAAM,QAAQ,MAAM,EAAE;GACxB,MAAM,SAAS,qBAAqB,MAAkB;AACtD,OAAI,OAAQ,QAAO;;;CAMzB,MAAM,aAAa,QAAQ,MAAM,QAAQ;AACzC,KAAI,cAAc,OAAO,eAAe,UAAU;EAChD,MAAM,SAAS,oBAAoB,WAAW;AAC9C,MAAI,OAAQ,QAAO;;CAIrB,MAAM,eAAe,QAAQ,MAAM,QAAQ;AAC3C,KAAI,gBAAgB,OAAO,iBAAiB;OACrC,MAAM,SAAS,OAAO,OAAO,aAAa,CAC7C,KAAI,SAAS,OAAO,UAAU,YAAY,kBAAkB,OAAO;GACjE,MAAM,SAAS,oBACZ,MAAkC,aAIpC;AACD,OAAI,OAAQ,QAAO;;;AAKzB,QAAO;;;;;;AAOT,SAAS,qBACP,MACgE;AAChE,MAAK,MAAM,OAAO,MAAM;AACtB,MAAI,OAAO,QAAQ,SAAU;EAE7B,MAAM,UAAU,IAAI,MAAM,eAAe,CAAC,GAAG,MAAM;AACnD,MAAI,SAAS;GACX,MAAM,SAAS,oBAAoB,QAAQ;AAC3C,OAAI,OAAQ,QAAO;;;AAGvB,QAAO;;;;;;AAOT,SAAS,oBACP,MACgE;AAChE,MAAK,MAAM,OAAO,OAAO,KAAK,KAAK,EAAE;EACnC,MAAM,SAAS,oBAAoB,IAAI;AACvC,MAAI,OAAQ,QAAO;;AAErB,QAAO"}
@@ -1,21 +1,23 @@
1
- import { resolveGtDependency } from './resolveGtDependency.js';
1
+ import { resolveGtDependency } from "./resolveGtDependency.js";
2
+ //#region src/fs/determineFramework/matchRequirementsTxtDependency.ts
2
3
  /**
3
- * Parse requirements.txt for GT dependencies.
4
- * Each line is a package specification: package[extras]>=version
5
- */
6
- export function matchRequirementsTxtDependency(content) {
7
- const lines = content.split('\n');
8
- for (const line of lines) {
9
- const trimmed = line.split('#')[0].trim();
10
- if (!trimmed || trimmed.startsWith('-'))
11
- continue;
12
- // Extract package name before version specifiers, extras, or markers
13
- const pkgName = trimmed.split(/[><=!~;@\s[]/)[0].trim();
14
- if (pkgName) {
15
- const result = resolveGtDependency(pkgName);
16
- if (result)
17
- return result;
18
- }
19
- }
20
- return null;
4
+ * Parse requirements.txt for GT dependencies.
5
+ * Each line is a package specification: package[extras]>=version
6
+ */
7
+ function matchRequirementsTxtDependency(content) {
8
+ const lines = content.split("\n");
9
+ for (const line of lines) {
10
+ const trimmed = line.split("#")[0].trim();
11
+ if (!trimmed || trimmed.startsWith("-")) continue;
12
+ const pkgName = trimmed.split(/[><=!~;@\s[]/)[0].trim();
13
+ if (pkgName) {
14
+ const result = resolveGtDependency(pkgName);
15
+ if (result) return result;
16
+ }
17
+ }
18
+ return null;
21
19
  }
20
+ //#endregion
21
+ export { matchRequirementsTxtDependency };
22
+
23
+ //# sourceMappingURL=matchRequirementsTxtDependency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchRequirementsTxtDependency.js","names":[],"sources":["../../../src/fs/determineFramework/matchRequirementsTxtDependency.ts"],"sourcesContent":["import { Libraries } from '../../types/libraries.js';\nimport { resolveGtDependency } from './resolveGtDependency.js';\n\n/**\n * Parse requirements.txt for GT dependencies.\n * Each line is a package specification: package[extras]>=version\n */\nexport function matchRequirementsTxtDependency(\n content: string\n): typeof Libraries.GT_FLASK | typeof Libraries.GT_FASTAPI | null {\n const lines = content.split('\\n');\n for (const line of lines) {\n const trimmed = line.split('#')[0].trim();\n if (!trimmed || trimmed.startsWith('-')) continue;\n // Extract package name before version specifiers, extras, or markers\n const pkgName = trimmed.split(/[><=!~;@\\s[]/)[0].trim();\n if (pkgName) {\n const result = resolveGtDependency(pkgName);\n if (result) return result;\n }\n }\n return null;\n}\n"],"mappings":";;;;;;AAOA,SAAgB,+BACd,SACgE;CAChE,MAAM,QAAQ,QAAQ,MAAM,KAAK;AACjC,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,UAAU,KAAK,MAAM,IAAI,CAAC,GAAG,MAAM;AACzC,MAAI,CAAC,WAAW,QAAQ,WAAW,IAAI,CAAE;EAEzC,MAAM,UAAU,QAAQ,MAAM,eAAe,CAAC,GAAG,MAAM;AACvD,MAAI,SAAS;GACX,MAAM,SAAS,oBAAoB,QAAQ;AAC3C,OAAI,OAAQ,QAAO;;;AAGvB,QAAO"}
@@ -1,86 +1,65 @@
1
- import { resolveGtDependency } from './resolveGtDependency.js';
1
+ import { resolveGtDependency } from "./resolveGtDependency.js";
2
+ //#region src/fs/determineFramework/matchSetupPyDependency.ts
2
3
  /**
3
- * Parse setup.py for GT dependencies.
4
- * Extracts quoted strings from install_requires or extras_require blocks
5
- * and matches against GT packages.
6
- */
7
- export function matchSetupPyDependency(content) {
8
- // Find install_requires=[...] and extras_require={...:[...]} blocks
9
- // and extract quoted dependency strings from within them.
10
- // We search for the keyword, then collect quoted strings until the
11
- // corresponding closing bracket.
12
- const dependencyKeywords = ['install_requires', 'extras_require'];
13
- for (const keyword of dependencyKeywords) {
14
- const keywordIndex = content.indexOf(keyword);
15
- if (keywordIndex === -1)
16
- continue;
17
- // Find the opening bracket after the keyword
18
- const afterKeyword = content.slice(keywordIndex + keyword.length);
19
- const bracketMatch = afterKeyword.match(/\s*=\s*(?:\[|{)/);
20
- if (!bracketMatch)
21
- continue;
22
- const openBracket = afterKeyword[bracketMatch.index + bracketMatch[0].length - 1];
23
- const closeBracket = openBracket === '[' ? ']' : '}';
24
- // Extract the content between brackets
25
- const startIndex = keywordIndex +
26
- keyword.length +
27
- bracketMatch.index +
28
- bracketMatch[0].length;
29
- const closeIndex = findMatchingBracket(content, startIndex - 1, openBracket, closeBracket);
30
- if (closeIndex === -1)
31
- continue;
32
- const blockContent = content.slice(startIndex, closeIndex);
33
- // Extract all quoted strings from the block
34
- const quotedStrings = blockContent.match(/["']([^"']+)["']/g);
35
- if (!quotedStrings)
36
- continue;
37
- for (const match of quotedStrings) {
38
- const value = match.slice(1, -1);
39
- const pkgName = value.split(/[><=!~;@\s[]/)[0].trim();
40
- if (pkgName) {
41
- const result = resolveGtDependency(pkgName);
42
- if (result)
43
- return result;
44
- }
45
- }
46
- }
47
- return null;
4
+ * Parse setup.py for GT dependencies.
5
+ * Extracts quoted strings from install_requires or extras_require blocks
6
+ * and matches against GT packages.
7
+ */
8
+ function matchSetupPyDependency(content) {
9
+ for (const keyword of ["install_requires", "extras_require"]) {
10
+ const keywordIndex = content.indexOf(keyword);
11
+ if (keywordIndex === -1) continue;
12
+ const afterKeyword = content.slice(keywordIndex + keyword.length);
13
+ const bracketMatch = afterKeyword.match(/\s*=\s*(?:\[|{)/);
14
+ if (!bracketMatch) continue;
15
+ const openBracket = afterKeyword[bracketMatch.index + bracketMatch[0].length - 1];
16
+ const closeBracket = openBracket === "[" ? "]" : "}";
17
+ const startIndex = keywordIndex + keyword.length + bracketMatch.index + bracketMatch[0].length;
18
+ const closeIndex = findMatchingBracket(content, startIndex - 1, openBracket, closeBracket);
19
+ if (closeIndex === -1) continue;
20
+ const quotedStrings = content.slice(startIndex, closeIndex).match(/["']([^"']+)["']/g);
21
+ if (!quotedStrings) continue;
22
+ for (const match of quotedStrings) {
23
+ const pkgName = match.slice(1, -1).split(/[><=!~;@\s[]/)[0].trim();
24
+ if (pkgName) {
25
+ const result = resolveGtDependency(pkgName);
26
+ if (result) return result;
27
+ }
28
+ }
29
+ }
30
+ return null;
48
31
  }
49
32
  /**
50
- * Find the matching closing bracket, handling nesting.
51
- */
33
+ * Find the matching closing bracket, handling nesting.
34
+ */
52
35
  function findMatchingBracket(content, startIndex, openBracket, closeBracket) {
53
- let depth = 0;
54
- let inString = false;
55
- let stringChar = '';
56
- for (let i = startIndex; i < content.length; i++) {
57
- const ch = content[i];
58
- // Track string boundaries to avoid counting brackets inside strings
59
- if (!inString && (ch === '"' || ch === "'")) {
60
- inString = true;
61
- stringChar = ch;
62
- }
63
- else if (inString && ch === stringChar) {
64
- // Count consecutive backslashes before this quote
65
- let backslashes = 0;
66
- let j = i - 1;
67
- while (j >= 0 && content[j] === '\\') {
68
- backslashes++;
69
- j--;
70
- }
71
- if (backslashes % 2 === 0)
72
- inString = false;
73
- }
74
- if (inString)
75
- continue;
76
- if (ch === openBracket) {
77
- depth++;
78
- }
79
- else if (ch === closeBracket) {
80
- depth--;
81
- if (depth === 0)
82
- return i;
83
- }
84
- }
85
- return -1;
36
+ let depth = 0;
37
+ let inString = false;
38
+ let stringChar = "";
39
+ for (let i = startIndex; i < content.length; i++) {
40
+ const ch = content[i];
41
+ if (!inString && (ch === "\"" || ch === "'")) {
42
+ inString = true;
43
+ stringChar = ch;
44
+ } else if (inString && ch === stringChar) {
45
+ let backslashes = 0;
46
+ let j = i - 1;
47
+ while (j >= 0 && content[j] === "\\") {
48
+ backslashes++;
49
+ j--;
50
+ }
51
+ if (backslashes % 2 === 0) inString = false;
52
+ }
53
+ if (inString) continue;
54
+ if (ch === openBracket) depth++;
55
+ else if (ch === closeBracket) {
56
+ depth--;
57
+ if (depth === 0) return i;
58
+ }
59
+ }
60
+ return -1;
86
61
  }
62
+ //#endregion
63
+ export { matchSetupPyDependency };
64
+
65
+ //# sourceMappingURL=matchSetupPyDependency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchSetupPyDependency.js","names":[],"sources":["../../../src/fs/determineFramework/matchSetupPyDependency.ts"],"sourcesContent":["import { Libraries } from '../../types/libraries.js';\nimport { resolveGtDependency } from './resolveGtDependency.js';\n\n/**\n * Parse setup.py for GT dependencies.\n * Extracts quoted strings from install_requires or extras_require blocks\n * and matches against GT packages.\n */\nexport function matchSetupPyDependency(\n content: string\n): typeof Libraries.GT_FLASK | typeof Libraries.GT_FASTAPI | null {\n // Find install_requires=[...] and extras_require={...:[...]} blocks\n // and extract quoted dependency strings from within them.\n // We search for the keyword, then collect quoted strings until the\n // corresponding closing bracket.\n const dependencyKeywords = ['install_requires', 'extras_require'];\n\n for (const keyword of dependencyKeywords) {\n const keywordIndex = content.indexOf(keyword);\n if (keywordIndex === -1) continue;\n\n // Find the opening bracket after the keyword\n const afterKeyword = content.slice(keywordIndex + keyword.length);\n const bracketMatch = afterKeyword.match(/\\s*=\\s*(?:\\[|{)/);\n if (!bracketMatch) continue;\n\n const openBracket =\n afterKeyword[bracketMatch.index! + bracketMatch[0].length - 1];\n const closeBracket = openBracket === '[' ? ']' : '}';\n\n // Extract the content between brackets\n const startIndex =\n keywordIndex +\n keyword.length +\n bracketMatch.index! +\n bracketMatch[0].length;\n const closeIndex = findMatchingBracket(\n content,\n startIndex - 1,\n openBracket,\n closeBracket\n );\n if (closeIndex === -1) continue;\n\n const blockContent = content.slice(startIndex, closeIndex);\n\n // Extract all quoted strings from the block\n const quotedStrings = blockContent.match(/[\"']([^\"']+)[\"']/g);\n if (!quotedStrings) continue;\n\n for (const match of quotedStrings) {\n const value = match.slice(1, -1);\n const pkgName = value.split(/[><=!~;@\\s[]/)[0].trim();\n if (pkgName) {\n const result = resolveGtDependency(pkgName);\n if (result) return result;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Find the matching closing bracket, handling nesting.\n */\nfunction findMatchingBracket(\n content: string,\n startIndex: number,\n openBracket: string,\n closeBracket: string\n): number {\n let depth = 0;\n let inString = false;\n let stringChar = '';\n\n for (let i = startIndex; i < content.length; i++) {\n const ch = content[i];\n\n // Track string boundaries to avoid counting brackets inside strings\n if (!inString && (ch === '\"' || ch === \"'\")) {\n inString = true;\n stringChar = ch;\n } else if (inString && ch === stringChar) {\n // Count consecutive backslashes before this quote\n let backslashes = 0;\n let j = i - 1;\n while (j >= 0 && content[j] === '\\\\') {\n backslashes++;\n j--;\n }\n if (backslashes % 2 === 0) inString = false;\n }\n\n if (inString) continue;\n\n if (ch === openBracket) {\n depth++;\n } else if (ch === closeBracket) {\n depth--;\n if (depth === 0) return i;\n }\n }\n\n return -1;\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,uBACd,SACgE;AAOhE,MAAK,MAAM,WAAW,CAFM,oBAAoB,iBAER,EAAE;EACxC,MAAM,eAAe,QAAQ,QAAQ,QAAQ;AAC7C,MAAI,iBAAiB,GAAI;EAGzB,MAAM,eAAe,QAAQ,MAAM,eAAe,QAAQ,OAAO;EACjE,MAAM,eAAe,aAAa,MAAM,kBAAkB;AAC1D,MAAI,CAAC,aAAc;EAEnB,MAAM,cACJ,aAAa,aAAa,QAAS,aAAa,GAAG,SAAS;EAC9D,MAAM,eAAe,gBAAgB,MAAM,MAAM;EAGjD,MAAM,aACJ,eACA,QAAQ,SACR,aAAa,QACb,aAAa,GAAG;EAClB,MAAM,aAAa,oBACjB,SACA,aAAa,GACb,aACA,aACD;AACD,MAAI,eAAe,GAAI;EAKvB,MAAM,gBAHe,QAAQ,MAAM,YAAY,WAGb,CAAC,MAAM,oBAAoB;AAC7D,MAAI,CAAC,cAAe;AAEpB,OAAK,MAAM,SAAS,eAAe;GAEjC,MAAM,UADQ,MAAM,MAAM,GAAG,GACR,CAAC,MAAM,eAAe,CAAC,GAAG,MAAM;AACrD,OAAI,SAAS;IACX,MAAM,SAAS,oBAAoB,QAAQ;AAC3C,QAAI,OAAQ,QAAO;;;;AAKzB,QAAO;;;;;AAMT,SAAS,oBACP,SACA,YACA,aACA,cACQ;CACR,IAAI,QAAQ;CACZ,IAAI,WAAW;CACf,IAAI,aAAa;AAEjB,MAAK,IAAI,IAAI,YAAY,IAAI,QAAQ,QAAQ,KAAK;EAChD,MAAM,KAAK,QAAQ;AAGnB,MAAI,CAAC,aAAa,OAAO,QAAO,OAAO,MAAM;AAC3C,cAAW;AACX,gBAAa;aACJ,YAAY,OAAO,YAAY;GAExC,IAAI,cAAc;GAClB,IAAI,IAAI,IAAI;AACZ,UAAO,KAAK,KAAK,QAAQ,OAAO,MAAM;AACpC;AACA;;AAEF,OAAI,cAAc,MAAM,EAAG,YAAW;;AAGxC,MAAI,SAAU;AAEd,MAAI,OAAO,YACT;WACS,OAAO,cAAc;AAC9B;AACA,OAAI,UAAU,EAAG,QAAO;;;AAI5B,QAAO"}
@@ -1,17 +1,17 @@
1
- import { Libraries } from '../../types/libraries.js';
2
- import { PYTHON_GT_DEPENDENCIES } from '@generaltranslation/python-extractor';
1
+ import "../../types/libraries.js";
2
+ import { PYTHON_GT_DEPENDENCIES } from "@generaltranslation/python-extractor";
3
+ //#region src/fs/determineFramework/resolveGtDependency.ts
3
4
  /**
4
- * Resolve a dependency name (hyphenated or underscored) to a Python GT library.
5
- * Per PEP 503, Python package names are normalized: hyphens, underscores, and
6
- * periods are interchangeable. We match both gt-flask/gt_flask forms.
7
- */
8
- export function resolveGtDependency(pkgName) {
9
- // Normalize: replace underscores/periods with hyphens, lowercase
10
- const normalized = pkgName.toLowerCase().replace(/[_.]/g, '-');
11
- for (const dep of PYTHON_GT_DEPENDENCIES) {
12
- if (normalized === dep) {
13
- return dep === 'gt-flask' ? Libraries.GT_FLASK : Libraries.GT_FASTAPI;
14
- }
15
- }
16
- return null;
5
+ * Resolve a dependency name (hyphenated or underscored) to a Python GT library.
6
+ * Per PEP 503, Python package names are normalized: hyphens, underscores, and
7
+ * periods are interchangeable. We match both gt-flask/gt_flask forms.
8
+ */
9
+ function resolveGtDependency(pkgName) {
10
+ const normalized = pkgName.toLowerCase().replace(/[_.]/g, "-");
11
+ for (const dep of PYTHON_GT_DEPENDENCIES) if (normalized === dep) return dep === "gt-flask" ? "gt-flask" : "gt-fastapi";
12
+ return null;
17
13
  }
14
+ //#endregion
15
+ export { resolveGtDependency };
16
+
17
+ //# sourceMappingURL=resolveGtDependency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveGtDependency.js","names":[],"sources":["../../../src/fs/determineFramework/resolveGtDependency.ts"],"sourcesContent":["import { Libraries } from '../../types/libraries.js';\nimport { PYTHON_GT_DEPENDENCIES } from '@generaltranslation/python-extractor';\n\n/**\n * Resolve a dependency name (hyphenated or underscored) to a Python GT library.\n * Per PEP 503, Python package names are normalized: hyphens, underscores, and\n * periods are interchangeable. We match both gt-flask/gt_flask forms.\n */\nexport function resolveGtDependency(\n pkgName: string\n): typeof Libraries.GT_FLASK | typeof Libraries.GT_FASTAPI | null {\n // Normalize: replace underscores/periods with hyphens, lowercase\n const normalized = pkgName.toLowerCase().replace(/[_.]/g, '-');\n for (const dep of PYTHON_GT_DEPENDENCIES) {\n if (normalized === dep) {\n return dep === 'gt-flask' ? Libraries.GT_FLASK : Libraries.GT_FASTAPI;\n }\n }\n return null;\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,oBACd,SACgE;CAEhE,MAAM,aAAa,QAAQ,aAAa,CAAC,QAAQ,SAAS,IAAI;AAC9D,MAAK,MAAM,OAAO,uBAChB,KAAI,eAAe,IACjB,QAAO,QAAQ,aAAA,aAAA;AAGnB,QAAO"}
@@ -1,90 +1,75 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { logger } from '../console/logger.js';
4
- import { exitSync } from '../console/logging.js';
1
+ import { logger } from "../console/logger.js";
2
+ import { exitSync } from "../console/logging.js";
3
+ import path from "node:path";
4
+ import fs from "node:fs";
5
+ //#region src/fs/findFilepath.ts
5
6
  /**
6
- * Resolve the file path from the given file path or default paths.
7
- * @param {string} filePath - The file path to resolve.
8
- * @param {string[]} defaultPaths - The default paths to check.
9
- * @returns {string} - The resolved file path.
10
- */
11
- export default function findFilepath(paths, errorMessage = '') {
12
- return findFilepaths(paths, errorMessage)?.[0] || '';
7
+ * Resolve the file path from the given file path or default paths.
8
+ * @param {string} filePath - The file path to resolve.
9
+ * @param {string[]} defaultPaths - The default paths to check.
10
+ * @returns {string} - The resolved file path.
11
+ */
12
+ function findFilepath(paths, errorMessage = "") {
13
+ return findFilepaths(paths, errorMessage)?.[0] || "";
13
14
  }
14
15
  /**
15
- * Resolve the file paths from the given file paths or default paths.
16
- * @param {string[]} paths - The file paths to resolve.
17
- * @param {string} errorMessage - The error message to throw if no paths are found.
18
- * @returns {string[]} - The resolved file paths.
19
- */
20
- export function findFilepaths(paths, errorMessage = '') {
21
- const resolvedPaths = [];
22
- for (const possiblePath of paths) {
23
- if (fs.existsSync(possiblePath)) {
24
- resolvedPaths.push(possiblePath);
25
- }
26
- }
27
- if (errorMessage) {
28
- logger.error(errorMessage);
29
- exitSync(1);
30
- }
31
- return resolvedPaths;
16
+ * Resolve the file paths from the given file paths or default paths.
17
+ * @param {string[]} paths - The file paths to resolve.
18
+ * @param {string} errorMessage - The error message to throw if no paths are found.
19
+ * @returns {string[]} - The resolved file paths.
20
+ */
21
+ function findFilepaths(paths, errorMessage = "") {
22
+ const resolvedPaths = [];
23
+ for (const possiblePath of paths) if (fs.existsSync(possiblePath)) resolvedPaths.push(possiblePath);
24
+ if (errorMessage) {
25
+ logger.error(errorMessage);
26
+ exitSync(1);
27
+ }
28
+ return resolvedPaths;
32
29
  }
33
- export function getRelativePath(file, srcDirectory) {
34
- // Create relative path from src directory and remove extension
35
- return path
36
- .relative(srcDirectory, file.replace(/\.[^/.]+$/, '') // Remove file extension
37
- )
38
- .replace(/\\/g, '.') // Replace Windows backslashes with dots
39
- .split(/[./]/) // Split on dots or forward slashes
40
- .filter(Boolean) // Remove empty segments that might cause extra dots
41
- .map((segment) => segment.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()) // Convert each segment to snake case
42
- .join('.'); // Rejoin with dots
30
+ function getRelativePath(file, srcDirectory) {
31
+ return path.relative(srcDirectory, file.replace(/\.[^/.]+$/, "")).replace(/\\/g, ".").split(/[./]/).filter(Boolean).map((segment) => segment.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase()).join(".");
43
32
  }
44
33
  /**
45
- * Find a file in a directory based on a wildcard pattern.
46
- * @param {string} filePattern - The wildcard pattern to search for.
47
- * @param {string} file - The file to search for.
48
- * @returns {string} - The path to the file.
49
- */
50
- export function findFile(filePattern, file) {
51
- // Handle wildcard pattern by replacing the wildcard with the file parameter
52
- const resolvedPath = filePattern.replace(/\*/, file);
53
- if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {
54
- return fs.readFileSync(resolvedPath, 'utf8');
55
- }
56
- return '';
34
+ * Find a file in a directory based on a wildcard pattern.
35
+ * @param {string} filePattern - The wildcard pattern to search for.
36
+ * @param {string} file - The file to search for.
37
+ * @returns {string} - The path to the file.
38
+ */
39
+ function findFile(filePattern, file) {
40
+ const resolvedPath = filePattern.replace(/\*/, file);
41
+ if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) return fs.readFileSync(resolvedPath, "utf8");
42
+ return "";
57
43
  }
58
44
  /**
59
- * Read a file and return the contents.
60
- * @param {string} filePath - The path to the file to read.
61
- * @returns {string} - The contents of the file.
62
- */
63
- export function readFile(filePath) {
64
- if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {
65
- return fs.readFileSync(filePath, 'utf8');
66
- }
67
- return '';
45
+ * Read a file and return the contents.
46
+ * @param {string} filePath - The path to the file to read.
47
+ * @returns {string} - The contents of the file.
48
+ */
49
+ function readFile(filePath) {
50
+ if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) return fs.readFileSync(filePath, "utf8");
51
+ return "";
68
52
  }
69
53
  /**
70
- * Find a file in a directory.
71
- * @param {string} dir - The directory to search in.
72
- * @param {string} file - The file to search for.
73
- * @returns {string} - The path to the file.
74
- */
75
- export function findFileInDir(dir, file) {
76
- const resolvedPath = path.join(dir, file);
77
- try {
78
- if (fs.existsSync(resolvedPath)) {
79
- return fs.readFileSync(resolvedPath, 'utf8');
80
- }
81
- }
82
- catch (error) {
83
- logger.error('Error finding file in directory: ' + String(error));
84
- }
85
- return '';
54
+ * Find a file in a directory.
55
+ * @param {string} dir - The directory to search in.
56
+ * @param {string} file - The file to search for.
57
+ * @returns {string} - The path to the file.
58
+ */
59
+ function findFileInDir(dir, file) {
60
+ const resolvedPath = path.join(dir, file);
61
+ try {
62
+ if (fs.existsSync(resolvedPath)) return fs.readFileSync(resolvedPath, "utf8");
63
+ } catch (error) {
64
+ logger.error("Error finding file in directory: " + String(error));
65
+ }
66
+ return "";
86
67
  }
87
- export function getRelative(absolutePath) {
88
- const path2 = path.resolve(absolutePath);
89
- return path.relative(process.cwd(), path2);
68
+ function getRelative(absolutePath) {
69
+ const path2 = path.resolve(absolutePath);
70
+ return path.relative(process.cwd(), path2);
90
71
  }
72
+ //#endregion
73
+ export { findFilepath as default, findFile, findFileInDir, findFilepaths, getRelative, getRelativePath, readFile };
74
+
75
+ //# sourceMappingURL=findFilepath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findFilepath.js","names":[],"sources":["../../src/fs/findFilepath.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../console/logger.js';\nimport { exitSync } from '../console/logging.js';\n\n/**\n * Resolve the file path from the given file path or default paths.\n * @param {string} filePath - The file path to resolve.\n * @param {string[]} defaultPaths - The default paths to check.\n * @returns {string} - The resolved file path.\n */\nexport default function findFilepath(\n paths: string[],\n errorMessage: string = ''\n): string {\n return findFilepaths(paths, errorMessage)?.[0] || '';\n}\n\n/**\n * Resolve the file paths from the given file paths or default paths.\n * @param {string[]} paths - The file paths to resolve.\n * @param {string} errorMessage - The error message to throw if no paths are found.\n * @returns {string[]} - The resolved file paths.\n */\nexport function findFilepaths(\n paths: string[],\n errorMessage: string = ''\n): string[] {\n const resolvedPaths: string[] = [];\n for (const possiblePath of paths) {\n if (fs.existsSync(possiblePath)) {\n resolvedPaths.push(possiblePath);\n }\n }\n if (errorMessage) {\n logger.error(errorMessage);\n exitSync(1);\n }\n return resolvedPaths;\n}\n\nexport function getRelativePath(file: string, srcDirectory: string): string {\n // Create relative path from src directory and remove extension\n return path\n .relative(\n srcDirectory,\n file.replace(/\\.[^/.]+$/, '') // Remove file extension\n )\n .replace(/\\\\/g, '.') // Replace Windows backslashes with dots\n .split(/[./]/) // Split on dots or forward slashes\n .filter(Boolean) // Remove empty segments that might cause extra dots\n .map((segment) => segment.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()) // Convert each segment to snake case\n .join('.'); // Rejoin with dots\n}\n\n/**\n * Find a file in a directory based on a wildcard pattern.\n * @param {string} filePattern - The wildcard pattern to search for.\n * @param {string} file - The file to search for.\n * @returns {string} - The path to the file.\n */\nexport function findFile(filePattern: string, file: string): string {\n // Handle wildcard pattern by replacing the wildcard with the file parameter\n const resolvedPath = filePattern.replace(/\\*/, file);\n\n if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {\n return fs.readFileSync(resolvedPath, 'utf8');\n }\n return '';\n}\n\n/**\n * Read a file and return the contents.\n * @param {string} filePath - The path to the file to read.\n * @returns {string} - The contents of the file.\n */\nexport function readFile(filePath: string): string {\n if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {\n return fs.readFileSync(filePath, 'utf8');\n }\n return '';\n}\n\n/**\n * Find a file in a directory.\n * @param {string} dir - The directory to search in.\n * @param {string} file - The file to search for.\n * @returns {string} - The path to the file.\n */\nexport function findFileInDir(dir: string, file: string): string {\n const resolvedPath = path.join(dir, file);\n try {\n if (fs.existsSync(resolvedPath)) {\n return fs.readFileSync(resolvedPath, 'utf8');\n }\n } catch (error) {\n logger.error('Error finding file in directory: ' + String(error));\n }\n return '';\n}\n\nexport function getRelative(absolutePath: string): string {\n const path2 = path.resolve(absolutePath);\n return path.relative(process.cwd(), path2);\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAwB,aACtB,OACA,eAAuB,IACf;AACR,QAAO,cAAc,OAAO,aAAa,GAAG,MAAM;;;;;;;;AASpD,SAAgB,cACd,OACA,eAAuB,IACb;CACV,MAAM,gBAA0B,EAAE;AAClC,MAAK,MAAM,gBAAgB,MACzB,KAAI,GAAG,WAAW,aAAa,CAC7B,eAAc,KAAK,aAAa;AAGpC,KAAI,cAAc;AAChB,SAAO,MAAM,aAAa;AAC1B,WAAS,EAAE;;AAEb,QAAO;;AAGT,SAAgB,gBAAgB,MAAc,cAA8B;AAE1E,QAAO,KACJ,SACC,cACA,KAAK,QAAQ,aAAa,GAAG,CAC9B,CACA,QAAQ,OAAO,IAAI,CACnB,MAAM,OAAO,CACb,OAAO,QAAQ,CACf,KAAK,YAAY,QAAQ,QAAQ,iBAAiB,IAAI,CAAC,aAAa,CAAC,CACrE,KAAK,IAAI;;;;;;;;AASd,SAAgB,SAAS,aAAqB,MAAsB;CAElE,MAAM,eAAe,YAAY,QAAQ,MAAM,KAAK;AAEpD,KAAI,GAAG,WAAW,aAAa,IAAI,GAAG,SAAS,aAAa,CAAC,QAAQ,CACnE,QAAO,GAAG,aAAa,cAAc,OAAO;AAE9C,QAAO;;;;;;;AAQT,SAAgB,SAAS,UAA0B;AACjD,KAAI,GAAG,WAAW,SAAS,IAAI,GAAG,SAAS,SAAS,CAAC,QAAQ,CAC3D,QAAO,GAAG,aAAa,UAAU,OAAO;AAE1C,QAAO;;;;;;;;AAST,SAAgB,cAAc,KAAa,MAAsB;CAC/D,MAAM,eAAe,KAAK,KAAK,KAAK,KAAK;AACzC,KAAI;AACF,MAAI,GAAG,WAAW,aAAa,CAC7B,QAAO,GAAG,aAAa,cAAc,OAAO;UAEvC,OAAO;AACd,SAAO,MAAM,sCAAsC,OAAO,MAAM,CAAC;;AAEnE,QAAO;;AAGT,SAAgB,YAAY,cAA8B;CACxD,MAAM,QAAQ,KAAK,QAAQ,aAAa;AACxC,QAAO,KAAK,SAAS,QAAQ,KAAK,EAAE,MAAM"}
@@ -1,17 +1,20 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ //#region src/fs/loadJSON.ts
3
4
  /**
4
- * Loads a JSON file from a given filepath, returning null if the file is not found or the JSON doesn't parse.
5
- * @param {string} filepath - The path to the JSON file.
6
- * @returns {Record<string, any> | null} - The parsed JSON object or null if an error occurs.
7
- */
8
- export default function loadJSON(filepath) {
9
- try {
10
- const data = fs.readFileSync(path.resolve(filepath), 'utf-8');
11
- return JSON.parse(data);
12
- }
13
- catch {
14
- // Return null if the file is not found or JSON parsing fails
15
- return null;
16
- }
5
+ * Loads a JSON file from a given filepath, returning null if the file is not found or the JSON doesn't parse.
6
+ * @param {string} filepath - The path to the JSON file.
7
+ * @returns {Record<string, any> | null} - The parsed JSON object or null if an error occurs.
8
+ */
9
+ function loadJSON(filepath) {
10
+ try {
11
+ const data = fs.readFileSync(path.resolve(filepath), "utf-8");
12
+ return JSON.parse(data);
13
+ } catch {
14
+ return null;
15
+ }
17
16
  }
17
+ //#endregion
18
+ export { loadJSON as default };
19
+
20
+ //# sourceMappingURL=loadJSON.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadJSON.js","names":[],"sources":["../../src/fs/loadJSON.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * Loads a JSON file from a given filepath, returning null if the file is not found or the JSON doesn't parse.\n * @param {string} filepath - The path to the JSON file.\n * @returns {Record<string, any> | null} - The parsed JSON object or null if an error occurs.\n */\nexport default function loadJSON(\n filepath: string\n): Record<string, unknown> | null {\n try {\n const data = fs.readFileSync(path.resolve(filepath), 'utf-8');\n return JSON.parse(data);\n } catch {\n // Return null if the file is not found or JSON parsing fails\n return null;\n }\n}\n"],"mappings":";;;;;;;;AAQA,SAAwB,SACtB,UACgC;AAChC,KAAI;EACF,MAAM,OAAO,GAAG,aAAa,KAAK,QAAQ,SAAS,EAAE,QAAQ;AAC7D,SAAO,KAAK,MAAM,KAAK;SACjB;AAEN,SAAO"}