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.
- package/CHANGELOG.md +22 -1
- package/dist/api/collectUserEditDiffs.js +112 -155
- package/dist/api/collectUserEditDiffs.js.map +1 -0
- package/dist/api/downloadFileBatch.js +164 -241
- package/dist/api/downloadFileBatch.js.map +1 -0
- package/dist/api/saveLocalEdits.js +37 -41
- package/dist/api/saveLocalEdits.js.map +1 -0
- package/dist/bin/bin-entry.js +17 -7
- package/dist/bin/bin-entry.js.map +1 -0
- package/dist/bin/bin-main.js +43 -61
- package/dist/bin/bin-main.js.map +1 -0
- package/dist/cli/base.js +382 -497
- package/dist/cli/base.js.map +1 -0
- package/dist/cli/commands/download.js +41 -49
- package/dist/cli/commands/download.js.map +1 -0
- package/dist/cli/commands/enqueue.js +26 -25
- package/dist/cli/commands/enqueue.js.map +1 -0
- package/dist/cli/commands/setupProject.js +33 -36
- package/dist/cli/commands/setupProject.js.map +1 -0
- package/dist/cli/commands/stage.js +53 -61
- package/dist/cli/commands/stage.js.map +1 -0
- package/dist/cli/commands/translate.js +75 -112
- package/dist/cli/commands/translate.js.map +1 -0
- package/dist/cli/commands/upload.js +185 -213
- package/dist/cli/commands/upload.js.map +1 -0
- package/dist/cli/commands/utils/validation.js +39 -34
- package/dist/cli/commands/utils/validation.js.map +1 -0
- package/dist/cli/flags.js +35 -62
- package/dist/cli/flags.js.map +1 -0
- package/dist/cli/inline.js +112 -137
- package/dist/cli/inline.js.map +1 -0
- package/dist/cli/next.js +17 -12
- package/dist/cli/next.js.map +1 -0
- package/dist/cli/node.js +19 -15
- package/dist/cli/node.js.map +1 -0
- package/dist/cli/python.js +13 -8
- package/dist/cli/python.js.map +1 -0
- package/dist/cli/react.js +61 -78
- package/dist/cli/react.js.map +1 -0
- package/dist/config/defaults.js +16 -11
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/generateSettings.js +167 -269
- package/dist/config/generateSettings.js.map +1 -0
- package/dist/config/optionPresets.js +78 -96
- package/dist/config/optionPresets.js.map +1 -0
- package/dist/config/resolveConfig.js +27 -32
- package/dist/config/resolveConfig.js.map +1 -0
- package/dist/config/utils.js +7 -3
- package/dist/config/utils.js.map +1 -0
- package/dist/config/validateSettings.js +19 -30
- package/dist/config/validateSettings.js.map +1 -0
- package/dist/console/colors.js +18 -13
- package/dist/console/colors.js.map +1 -0
- package/dist/console/displayTranslateSummary.js +40 -37
- package/dist/console/displayTranslateSummary.js.map +1 -0
- package/dist/console/formatting.js +8 -5
- package/dist/console/formatting.js.map +1 -0
- package/dist/console/index.d.ts +11 -9
- package/dist/console/index.js +53 -50
- package/dist/console/index.js.map +1 -0
- package/dist/console/inkFields.d.ts +23 -0
- package/dist/console/inkFields.js +87 -0
- package/dist/console/inkFields.js.map +1 -0
- package/dist/console/inkLayout.d.ts +7 -0
- package/dist/console/inkLayout.js +139 -0
- package/dist/console/inkLayout.js.map +1 -0
- package/dist/console/inkLocaleData.d.ts +4 -0
- package/dist/console/inkLocaleData.js +32 -0
- package/dist/console/inkLocaleData.js.map +1 -0
- package/dist/console/inkPrompts.d.ts +8 -0
- package/dist/console/inkPrompts.js +496 -0
- package/dist/console/inkPrompts.js.map +1 -0
- package/dist/console/inkSession.d.ts +3 -0
- package/dist/console/inkSession.js +42 -0
- package/dist/console/inkSession.js.map +1 -0
- package/dist/console/inkTerminal.d.ts +4 -0
- package/dist/console/inkTerminal.js +15 -0
- package/dist/console/inkTerminal.js.map +1 -0
- package/dist/console/inkTypes.d.ts +66 -0
- package/dist/console/inkTypes.js +1 -0
- package/dist/console/inkUtils.d.ts +24 -0
- package/dist/console/inkUtils.js +87 -0
- package/dist/console/inkUtils.js.map +1 -0
- package/dist/console/logger.js +209 -249
- package/dist/console/logger.js.map +1 -0
- package/dist/console/logging.d.ts +14 -0
- package/dist/console/logging.js +203 -162
- package/dist/console/logging.js.map +1 -0
- package/dist/console/promptParsing.d.ts +5 -0
- package/dist/console/promptParsing.js +28 -0
- package/dist/console/promptParsing.js.map +1 -0
- package/dist/console/terminalSession.d.ts +5 -0
- package/dist/console/terminalSession.js +38 -0
- package/dist/console/terminalSession.js.map +1 -0
- package/dist/extraction/index.js +3 -2
- package/dist/extraction/mapToUpdates.js +19 -18
- package/dist/extraction/mapToUpdates.js.map +1 -0
- package/dist/extraction/postProcess.js +68 -86
- package/dist/extraction/postProcess.js.map +1 -0
- package/dist/formats/files/aggregateFiles.js +223 -304
- package/dist/formats/files/aggregateFiles.js.map +1 -0
- package/dist/formats/files/collectFiles.js +53 -54
- package/dist/formats/files/collectFiles.js.map +1 -0
- package/dist/formats/files/convertToFileTranslationData.js +21 -19
- package/dist/formats/files/convertToFileTranslationData.js.map +1 -0
- package/dist/formats/files/fileMapping.js +82 -119
- package/dist/formats/files/fileMapping.js.map +1 -0
- package/dist/formats/files/preprocess/mdx.js +15 -12
- package/dist/formats/files/preprocess/mdx.js.map +1 -0
- package/dist/formats/files/preprocess/mintlify.js +15 -13
- package/dist/formats/files/preprocess/mintlify.js.map +1 -0
- package/dist/formats/files/preprocessContent.js +20 -21
- package/dist/formats/files/preprocessContent.js.map +1 -0
- package/dist/formats/files/save.js +18 -15
- package/dist/formats/files/save.js.map +1 -0
- package/dist/formats/files/supportedFiles.js +27 -22
- package/dist/formats/files/supportedFiles.js.map +1 -0
- package/dist/formats/files/transformFormat.js +93 -100
- package/dist/formats/files/transformFormat.js.map +1 -0
- package/dist/formats/json/extractJson.js +83 -110
- package/dist/formats/json/extractJson.js.map +1 -0
- package/dist/formats/json/flattenJson.js +41 -48
- package/dist/formats/json/flattenJson.js.map +1 -0
- package/dist/formats/json/jsonPath.js +20 -15
- package/dist/formats/json/jsonPath.js.map +1 -0
- package/dist/formats/json/jsonPointer.js +17 -17
- package/dist/formats/json/jsonPointer.js.map +1 -0
- package/dist/formats/json/mergeJson.js +230 -371
- package/dist/formats/json/mergeJson.js.map +1 -0
- package/dist/formats/json/parseJson.js +74 -111
- package/dist/formats/json/parseJson.js.map +1 -0
- package/dist/formats/json/transformJson.js +53 -61
- package/dist/formats/json/transformJson.js.map +1 -0
- package/dist/formats/json/utils.js +158 -187
- package/dist/formats/json/utils.js.map +1 -0
- package/dist/formats/parseKeyedMetadata.js +85 -106
- package/dist/formats/parseKeyedMetadata.js.map +1 -0
- package/dist/formats/utils.js +13 -23
- package/dist/formats/utils.js.map +1 -0
- package/dist/formats/yaml/extractYaml.js +32 -31
- package/dist/formats/yaml/extractYaml.js.map +1 -0
- package/dist/formats/yaml/mergeYaml.js +43 -60
- package/dist/formats/yaml/mergeYaml.js.map +1 -0
- package/dist/formats/yaml/parseYaml.js +34 -23
- package/dist/formats/yaml/parseYaml.js.map +1 -0
- package/dist/formats/yaml/utils.js +19 -21
- package/dist/formats/yaml/utils.js.map +1 -0
- package/dist/fs/clearLocaleDirs.js +82 -114
- package/dist/fs/clearLocaleDirs.js.map +1 -0
- package/dist/fs/config/downloadedVersions.js +174 -188
- package/dist/fs/config/downloadedVersions.js.map +1 -0
- package/dist/fs/config/loadConfig.js +12 -8
- package/dist/fs/config/loadConfig.js.map +1 -0
- package/dist/fs/config/parseFilesConfig.js +166 -227
- package/dist/fs/config/parseFilesConfig.js.map +1 -0
- package/dist/fs/config/setupConfig.js +43 -52
- package/dist/fs/config/setupConfig.js.map +1 -0
- package/dist/fs/config/updateConfig.js +44 -56
- package/dist/fs/config/updateConfig.js.map +1 -0
- package/dist/fs/config/updateVersions.js +27 -28
- package/dist/fs/config/updateVersions.js.map +1 -0
- package/dist/fs/copyFile.js +33 -37
- package/dist/fs/copyFile.js.map +1 -0
- package/dist/fs/createLoadTranslationsFile.js +32 -48
- package/dist/fs/createLoadTranslationsFile.js.map +1 -0
- package/dist/fs/determineFramework/detectPythonLibrary.js +30 -34
- package/dist/fs/determineFramework/detectPythonLibrary.js.map +1 -0
- package/dist/fs/determineFramework/index.js +46 -64
- package/dist/fs/determineFramework/index.js.map +1 -0
- package/dist/fs/determineFramework/matchPyprojectDependency.js +65 -78
- package/dist/fs/determineFramework/matchPyprojectDependency.js.map +1 -0
- package/dist/fs/determineFramework/matchRequirementsTxtDependency.js +21 -19
- package/dist/fs/determineFramework/matchRequirementsTxtDependency.js.map +1 -0
- package/dist/fs/determineFramework/matchSetupPyDependency.js +60 -81
- package/dist/fs/determineFramework/matchSetupPyDependency.js.map +1 -0
- package/dist/fs/determineFramework/resolveGtDependency.js +15 -15
- package/dist/fs/determineFramework/resolveGtDependency.js.map +1 -0
- package/dist/fs/findFilepath.js +63 -78
- package/dist/fs/findFilepath.js.map +1 -0
- package/dist/fs/loadJSON.js +18 -15
- package/dist/fs/loadJSON.js.map +1 -0
- package/dist/fs/matchFiles.js +12 -7
- package/dist/fs/matchFiles.js.map +1 -0
- package/dist/fs/saveJSON.js +10 -6
- package/dist/fs/saveJSON.js.map +1 -0
- package/dist/fs/utils.js +19 -15
- package/dist/fs/utils.js.map +1 -0
- package/dist/functions.d.ts +2 -1
- package/dist/functions.js +3 -6
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +6 -2
- package/dist/generated/version.js.map +1 -0
- package/dist/git/branches.js +77 -83
- package/dist/git/branches.js.map +1 -0
- package/dist/hooks/postProcess.js +97 -114
- package/dist/hooks/postProcess.js.map +1 -0
- package/dist/index.js +23 -31
- package/dist/index.js.map +1 -0
- package/dist/locadex/setupFlow.js +11 -8
- package/dist/locadex/setupFlow.js.map +1 -0
- package/dist/main.js +17 -7
- package/dist/main.js.map +1 -0
- package/dist/next/config/parseNextConfig.js +32 -51
- package/dist/next/config/parseNextConfig.js.map +1 -0
- package/dist/next/jsx/utils.js +25 -37
- package/dist/next/jsx/utils.js.map +1 -0
- package/dist/next/parse/handleInitGT.js +87 -154
- package/dist/next/parse/handleInitGT.js.map +1 -0
- package/dist/next/parse/wrapContent.js +136 -158
- package/dist/next/parse/wrapContent.js.map +1 -0
- package/dist/python/parse/createPythonInlineUpdates.js +36 -33
- package/dist/python/parse/createPythonInlineUpdates.js.map +1 -0
- package/dist/react/config/createESBuildConfig.js +115 -115
- package/dist/react/config/createESBuildConfig.js.map +1 -0
- package/dist/react/jsx/evaluateJsx.js +90 -124
- package/dist/react/jsx/evaluateJsx.js.map +1 -0
- package/dist/react/jsx/utils/buildImportMap.js +24 -28
- package/dist/react/jsx/utils/buildImportMap.js.map +1 -0
- package/dist/react/jsx/utils/constants.js +79 -87
- package/dist/react/jsx/utils/constants.js.map +1 -0
- package/dist/react/jsx/utils/extractSourceCode.js +36 -37
- package/dist/react/jsx/utils/extractSourceCode.js.map +1 -0
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js +30 -30
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js.map +1 -0
- package/dist/react/jsx/utils/getPathsAndAliases.js +70 -105
- package/dist/react/jsx/utils/getPathsAndAliases.js.map +1 -0
- package/dist/react/jsx/utils/isNumberLiteral.js +13 -11
- package/dist/react/jsx/utils/isNumberLiteral.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +103 -148
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/autoInsertion.js +305 -389
- package/dist/react/jsx/utils/jsxParsing/autoInsertion.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +122 -193
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +50 -64
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +41 -68
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js +760 -1107
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js +35 -71
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +39 -58
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/types.js +10 -24
- package/dist/react/jsx/utils/jsxParsing/types.js.map +1 -0
- package/dist/react/jsx/utils/mapAttributeName.js +13 -13
- package/dist/react/jsx/utils/mapAttributeName.js.map +1 -0
- package/dist/react/jsx/utils/parseAst.js +142 -272
- package/dist/react/jsx/utils/parseAst.js.map +1 -0
- package/dist/react/jsx/utils/parseString.js +726 -1090
- package/dist/react/jsx/utils/parseString.js.map +1 -0
- package/dist/react/jsx/utils/parseStringFunction.js +274 -401
- package/dist/react/jsx/utils/parseStringFunction.js.map +1 -0
- package/dist/react/jsx/utils/resolveImportPath.d.ts +1 -1
- package/dist/react/jsx/utils/resolveImportPath.js +125 -108
- package/dist/react/jsx/utils/resolveImportPath.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js +18 -24
- package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js +412 -579
- package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/index.js +57 -67
- package/dist/react/jsx/utils/stringParsing/derivation/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js +26 -36
- package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js +29 -24
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js +34 -32
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +80 -117
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js +24 -19
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +18 -21
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +45 -50
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +54 -59
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +56 -69
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/validateStringFunction.js +21 -29
- package/dist/react/jsx/utils/validateStringFunction.js.map +1 -0
- package/dist/react/jsx/wrapJsx.js +192 -375
- package/dist/react/jsx/wrapJsx.js.map +1 -0
- package/dist/react/parse/addVitePlugin/index.js +40 -34
- package/dist/react/parse/addVitePlugin/index.js.map +1 -0
- package/dist/react/parse/addVitePlugin/installCompiler.js +18 -20
- package/dist/react/parse/addVitePlugin/installCompiler.js.map +1 -0
- package/dist/react/parse/addVitePlugin/updateViteConfig.js +107 -111
- package/dist/react/parse/addVitePlugin/updateViteConfig.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +23 -26
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +29 -43
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +70 -104
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +23 -29
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js.map +1 -0
- package/dist/react/parse/createDictionaryUpdates.js +121 -185
- package/dist/react/parse/createDictionaryUpdates.js.map +1 -0
- package/dist/react/parse/createInlineUpdates.js +123 -139
- package/dist/react/parse/createInlineUpdates.js.map +1 -0
- package/dist/react/parse/wrapContent.js +131 -156
- package/dist/react/parse/wrapContent.js.map +1 -0
- package/dist/react/utils/flattenDictionary.js +55 -70
- package/dist/react/utils/flattenDictionary.js.map +1 -0
- package/dist/react/utils/getEntryAndMetadata.js +14 -10
- package/dist/react/utils/getEntryAndMetadata.js.map +1 -0
- package/dist/react/utils/getVariableName.js +36 -33
- package/dist/react/utils/getVariableName.js.map +1 -0
- package/dist/setup/detectFramework.js +85 -102
- package/dist/setup/detectFramework.js.map +1 -0
- package/dist/setup/frameworkUtils.js +17 -28
- package/dist/setup/frameworkUtils.js.map +1 -0
- package/dist/setup/userInput.js +24 -31
- package/dist/setup/userInput.js.map +1 -0
- package/dist/setup/wizard.js +141 -143
- package/dist/setup/wizard.js.map +1 -0
- package/dist/state/mintlifyRefMap.js +12 -9
- package/dist/state/mintlifyRefMap.js.map +1 -0
- package/dist/state/recentDownloads.js +26 -23
- package/dist/state/recentDownloads.js.map +1 -0
- package/dist/state/translateWarnings.js +17 -8
- package/dist/state/translateWarnings.js.map +1 -0
- package/dist/translation/parse.js +77 -98
- package/dist/translation/parse.js.map +1 -0
- package/dist/translation/stage.js +28 -43
- package/dist/translation/stage.js.map +1 -0
- package/dist/translation/validate.js +68 -91
- package/dist/translation/validate.js.map +1 -0
- package/dist/types/libraries.js +93 -91
- package/dist/types/libraries.js.map +1 -0
- package/dist/types/parsing.js +19 -10
- package/dist/types/parsing.js.map +1 -0
- package/dist/utils/addExplicitAnchorIds.js +270 -389
- package/dist/utils/addExplicitAnchorIds.js.map +1 -0
- package/dist/utils/calculateTimeoutMs.js +11 -6
- package/dist/utils/calculateTimeoutMs.js.map +1 -0
- package/dist/utils/constants.js +15 -12
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/credentials.js +67 -114
- package/dist/utils/credentials.js.map +1 -0
- package/dist/utils/fetch.js +22 -20
- package/dist/utils/fetch.js.map +1 -0
- package/dist/utils/flattenJsonFiles.js +27 -34
- package/dist/utils/flattenJsonFiles.js.map +1 -0
- package/dist/utils/gitDiff.js +30 -32
- package/dist/utils/gitDiff.js.map +1 -0
- package/dist/utils/gt.js +7 -2
- package/dist/utils/gt.js.map +1 -0
- package/dist/utils/hash.js +14 -9
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/headers.js +10 -13
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/installPackage.js +70 -75
- package/dist/utils/installPackage.js.map +1 -0
- package/dist/utils/localizeRelativeAssets.js +114 -157
- package/dist/utils/localizeRelativeAssets.js.map +1 -0
- package/dist/utils/localizeStaticImports.js +229 -371
- package/dist/utils/localizeStaticImports.js.map +1 -0
- package/dist/utils/localizeStaticUrls.js +241 -424
- package/dist/utils/localizeStaticUrls.js.map +1 -0
- package/dist/utils/mintlifyTitleFallback.js +64 -72
- package/dist/utils/mintlifyTitleFallback.js.map +1 -0
- package/dist/utils/monorepoVersionCheck.js +177 -215
- package/dist/utils/monorepoVersionCheck.js.map +1 -0
- package/dist/utils/packageInfo.js +17 -16
- package/dist/utils/packageInfo.js.map +1 -0
- package/dist/utils/packageJson.js +51 -66
- package/dist/utils/packageJson.js.map +1 -0
- package/dist/utils/packageManager.js +237 -260
- package/dist/utils/packageManager.js.map +1 -0
- package/dist/utils/parse/needsCJS.js +36 -69
- package/dist/utils/parse/needsCJS.js.map +1 -0
- package/dist/utils/persistPostprocessHashes.js +30 -32
- package/dist/utils/persistPostprocessHashes.js.map +1 -0
- package/dist/utils/processAnchorIds.js +32 -54
- package/dist/utils/processAnchorIds.js.map +1 -0
- package/dist/utils/processOpenApi.js +469 -578
- package/dist/utils/processOpenApi.js.map +1 -0
- package/dist/utils/resolveMintlifyRefs.js +89 -105
- package/dist/utils/resolveMintlifyRefs.js.map +1 -0
- package/dist/utils/resolvePublish.js +46 -54
- package/dist/utils/resolvePublish.js.map +1 -0
- package/dist/utils/sanitizeFileContent.js +20 -27
- package/dist/utils/sanitizeFileContent.js.map +1 -0
- package/dist/utils/sharedStaticAssets.js +248 -366
- package/dist/utils/sharedStaticAssets.js.map +1 -0
- package/dist/utils/splitMintlifyLanguageRefs.js +208 -282
- package/dist/utils/splitMintlifyLanguageRefs.js.map +1 -0
- package/dist/utils/validateMdx.js +26 -23
- package/dist/utils/validateMdx.js.map +1 -0
- package/dist/utils/wrapPlainUrls.js +58 -70
- package/dist/utils/wrapPlainUrls.js.map +1 -0
- package/dist/workflows/download.js +92 -126
- package/dist/workflows/download.js.map +1 -0
- package/dist/workflows/enqueue.js +47 -54
- package/dist/workflows/enqueue.js.map +1 -0
- package/dist/workflows/publish.js +29 -29
- package/dist/workflows/publish.js.map +1 -0
- package/dist/workflows/setupProject.js +39 -40
- package/dist/workflows/setupProject.js.map +1 -0
- package/dist/workflows/stage.js +61 -65
- package/dist/workflows/stage.js.map +1 -0
- package/dist/workflows/steps/BranchStep.js +118 -163
- package/dist/workflows/steps/BranchStep.js.map +1 -0
- package/dist/workflows/steps/DownloadStep.js +107 -137
- package/dist/workflows/steps/DownloadStep.js.map +1 -0
- package/dist/workflows/steps/EnqueueStep.js +32 -32
- package/dist/workflows/steps/EnqueueStep.js.map +1 -0
- package/dist/workflows/steps/PollJobsStep.js +208 -292
- package/dist/workflows/steps/PollJobsStep.js.map +1 -0
- package/dist/workflows/steps/PublishStep.js +33 -38
- package/dist/workflows/steps/PublishStep.js.map +1 -0
- package/dist/workflows/steps/SetupStep.js +71 -72
- package/dist/workflows/steps/SetupStep.js.map +1 -0
- package/dist/workflows/steps/TagStep.js +39 -44
- package/dist/workflows/steps/TagStep.js.map +1 -0
- package/dist/workflows/steps/UploadSourcesStep.js +108 -140
- package/dist/workflows/steps/UploadSourcesStep.js.map +1 -0
- package/dist/workflows/steps/UploadTranslationsStep.js +61 -71
- package/dist/workflows/steps/UploadTranslationsStep.js.map +1 -0
- package/dist/workflows/steps/UserEditDiffsStep.js +32 -34
- package/dist/workflows/steps/UserEditDiffsStep.js.map +1 -0
- package/dist/workflows/steps/WorkflowStep.js +6 -2
- package/dist/workflows/steps/WorkflowStep.js.map +1 -0
- package/dist/workflows/upload.js +45 -46
- package/dist/workflows/upload.js.map +1 -0
- package/package.json +14 -7
|
@@ -1,86 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { resolveGtDependency } from "./resolveGtDependency.js";
|
|
2
|
+
import { parse } from "smol-toml";
|
|
3
|
+
//#region src/fs/determineFramework/matchPyprojectDependency.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
59
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
60
|
+
* Check Poetry-style dependency keys (e.g. { gt-flask = "^1.0" })
|
|
61
|
+
* for GT dependencies.
|
|
62
|
+
*/
|
|
79
63
|
function matchDependencyKeys(deps) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
1
|
+
import { resolveGtDependency } from "./resolveGtDependency.js";
|
|
2
|
+
//#region src/fs/determineFramework/matchRequirementsTxtDependency.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
1
|
+
import { resolveGtDependency } from "./resolveGtDependency.js";
|
|
2
|
+
//#region src/fs/determineFramework/matchSetupPyDependency.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
51
|
-
|
|
33
|
+
* Find the matching closing bracket, handling nesting.
|
|
34
|
+
*/
|
|
52
35
|
function findMatchingBracket(content, startIndex, openBracket, closeBracket) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
|
2
|
-
import { PYTHON_GT_DEPENDENCIES } from
|
|
1
|
+
import "../../types/libraries.js";
|
|
2
|
+
import { PYTHON_GT_DEPENDENCIES } from "@generaltranslation/python-extractor";
|
|
3
|
+
//#region src/fs/determineFramework/resolveGtDependency.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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"}
|
package/dist/fs/findFilepath.js
CHANGED
|
@@ -1,90 +1,75 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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"}
|
package/dist/fs/loadJSON.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
//#region src/fs/loadJSON.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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"}
|