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,397 +1,255 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { unified } from
|
|
6
|
-
import remarkParse from
|
|
7
|
-
import remarkMdx from
|
|
8
|
-
import remarkFrontmatter from
|
|
9
|
-
import { visit } from
|
|
1
|
+
import { createFileMapping } from "../formats/files/fileMapping.js";
|
|
2
|
+
import * as fs$1 from "fs";
|
|
3
|
+
import micromatch from "micromatch";
|
|
4
|
+
import * as path$1 from "path";
|
|
5
|
+
import { unified } from "unified";
|
|
6
|
+
import remarkParse from "remark-parse";
|
|
7
|
+
import remarkMdx from "remark-mdx";
|
|
8
|
+
import remarkFrontmatter from "remark-frontmatter";
|
|
9
|
+
import { visit } from "unist-util-visit";
|
|
10
|
+
//#region src/utils/localizeStaticImports.ts
|
|
10
11
|
const { isMatch } = micromatch;
|
|
11
12
|
/**
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const fileContent = await fs.promises.readFile(filePath, 'utf8');
|
|
53
|
-
// Localize the file using default locale
|
|
54
|
-
const localizedFile = localizeStaticImportsForFile(fileContent, settings.defaultLocale, settings.defaultLocale, // Process as default locale
|
|
55
|
-
settings.options?.docsHideDefaultLocaleImport || false, settings.options?.docsImportPattern, settings.options?.excludeStaticImports, filePath, settings.options);
|
|
56
|
-
// Write the localized file back to the same path
|
|
57
|
-
await fs.promises.writeFile(filePath, localizedFile);
|
|
58
|
-
}));
|
|
59
|
-
processPromises.push(defaultPromise);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Then process all other locales from fileMapping
|
|
63
|
-
const mappingPromises = Object.entries(fileMapping).map(async ([locale, filesMap]) => {
|
|
64
|
-
// Get all files that are md or mdx
|
|
65
|
-
const targetFiles = Object.values(filesMap).filter((p) => (p.endsWith('.md') || p.endsWith('.mdx')) &&
|
|
66
|
-
(!includeFiles || includeFiles.has(p)));
|
|
67
|
-
// Replace the placeholder path with the target path
|
|
68
|
-
await Promise.all(targetFiles.map(async (filePath) => {
|
|
69
|
-
// Check if file exists before processing
|
|
70
|
-
if (!fs.existsSync(filePath)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// Get file content
|
|
74
|
-
const fileContent = await fs.promises.readFile(filePath, 'utf8');
|
|
75
|
-
// Localize the file
|
|
76
|
-
const localizedFile = localizeStaticImportsForFile(fileContent, settings.defaultLocale, locale, settings.options?.docsHideDefaultLocaleImport || false, settings.options?.docsImportPattern, settings.options?.excludeStaticImports, filePath, settings.options);
|
|
77
|
-
// Write the localized file to the target path
|
|
78
|
-
await fs.promises.writeFile(filePath, localizedFile);
|
|
79
|
-
}));
|
|
80
|
-
});
|
|
81
|
-
processPromises.push(...mappingPromises);
|
|
82
|
-
await Promise.all(processPromises);
|
|
13
|
+
* Localizes static imports in content files.
|
|
14
|
+
* Currently only supported for md and mdx files. (/docs/ -> /[locale]/docs/)
|
|
15
|
+
* @param settings - The settings object containing the project configuration.
|
|
16
|
+
* @returns void
|
|
17
|
+
*
|
|
18
|
+
* @TODO This is an experimental feature, and only works in very specific cases. This needs to be improved before
|
|
19
|
+
* it can be enabled by default.
|
|
20
|
+
*
|
|
21
|
+
* Before this becomes a non-experimental feature, we need to:
|
|
22
|
+
* - Support more file types
|
|
23
|
+
* - Support more complex paths
|
|
24
|
+
*/
|
|
25
|
+
async function localizeStaticImports(settings, includeFiles) {
|
|
26
|
+
if (!settings.files || Object.keys(settings.files.placeholderPaths).length === 1 && settings.files.placeholderPaths.gt) return;
|
|
27
|
+
const { resolvedPaths: sourceFiles } = settings.files;
|
|
28
|
+
const fileMapping = createFileMapping(sourceFiles, settings.files.placeholderPaths, settings.files.transformPaths ?? {}, settings.files.transformFormats ?? {}, settings.locales, settings.defaultLocale);
|
|
29
|
+
const processPromises = [];
|
|
30
|
+
if (!fileMapping[settings.defaultLocale] && !includeFiles) {
|
|
31
|
+
const defaultLocaleFiles = [];
|
|
32
|
+
if (sourceFiles.md) defaultLocaleFiles.push(...sourceFiles.md);
|
|
33
|
+
if (sourceFiles.mdx) defaultLocaleFiles.push(...sourceFiles.mdx);
|
|
34
|
+
if (defaultLocaleFiles.length > 0) {
|
|
35
|
+
const defaultPromise = Promise.all(defaultLocaleFiles.map(async (filePath) => {
|
|
36
|
+
if (!fs$1.existsSync(filePath)) return;
|
|
37
|
+
const localizedFile = localizeStaticImportsForFile(await fs$1.promises.readFile(filePath, "utf8"), settings.defaultLocale, settings.defaultLocale, settings.options?.docsHideDefaultLocaleImport || false, settings.options?.docsImportPattern, settings.options?.excludeStaticImports, filePath, settings.options);
|
|
38
|
+
await fs$1.promises.writeFile(filePath, localizedFile);
|
|
39
|
+
}));
|
|
40
|
+
processPromises.push(defaultPromise);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const mappingPromises = Object.entries(fileMapping).map(async ([locale, filesMap]) => {
|
|
44
|
+
const targetFiles = Object.values(filesMap).filter((p) => (p.endsWith(".md") || p.endsWith(".mdx")) && (!includeFiles || includeFiles.has(p)));
|
|
45
|
+
await Promise.all(targetFiles.map(async (filePath) => {
|
|
46
|
+
if (!fs$1.existsSync(filePath)) return;
|
|
47
|
+
const localizedFile = localizeStaticImportsForFile(await fs$1.promises.readFile(filePath, "utf8"), settings.defaultLocale, locale, settings.options?.docsHideDefaultLocaleImport || false, settings.options?.docsImportPattern, settings.options?.excludeStaticImports, filePath, settings.options);
|
|
48
|
+
await fs$1.promises.writeFile(filePath, localizedFile);
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
51
|
+
processPromises.push(...mappingPromises);
|
|
52
|
+
await Promise.all(processPromises);
|
|
83
53
|
}
|
|
84
54
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
55
|
+
* Determines if an import path should be processed based on pattern matching
|
|
56
|
+
*/
|
|
87
57
|
function shouldProcessImportPath(importPath, patternHead, targetLocale, defaultLocale) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return importPath.includes(patternWithoutSlash);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
// For non-default locales, check if path starts with pattern
|
|
95
|
-
return importPath.includes(patternWithoutSlash);
|
|
96
|
-
}
|
|
58
|
+
const patternWithoutSlash = patternHead.replace(/\/$/, "");
|
|
59
|
+
if (targetLocale === defaultLocale) return importPath.includes(patternWithoutSlash);
|
|
60
|
+
else return importPath.includes(patternWithoutSlash);
|
|
97
61
|
}
|
|
98
62
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
63
|
+
* Checks if an import path should be excluded based on exclusion patterns
|
|
64
|
+
*/
|
|
101
65
|
function isImportPathExcluded(importPath, exclude, defaultLocale) {
|
|
102
|
-
|
|
103
|
-
return excludePatterns.some((pattern) => isMatch(importPath, pattern));
|
|
66
|
+
return exclude.map((p) => p.replace(/\[locale\]/g, defaultLocale)).some((pattern) => isMatch(importPath, pattern));
|
|
104
67
|
}
|
|
105
68
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
69
|
+
* Transforms import path for default locale processing
|
|
70
|
+
*/
|
|
108
71
|
function transformDefaultLocaleImportPath(fullPath, patternHead, defaultLocale, hideDefaultLocale) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
fullPath.endsWith(`/${defaultLocale}`)) {
|
|
123
|
-
return null; // Already has default locale
|
|
124
|
-
}
|
|
125
|
-
if (fullPath.startsWith(patternHead)) {
|
|
126
|
-
const pathAfterHead = fullPath.slice(patternHead.length);
|
|
127
|
-
if (pathAfterHead) {
|
|
128
|
-
return `${patternHead}${defaultLocale}/${pathAfterHead}`;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
return `${patternHead.replace(/\/$/, '')}/${defaultLocale}`;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return null; // Path doesn't match pattern
|
|
135
|
-
}
|
|
72
|
+
if (hideDefaultLocale) {
|
|
73
|
+
if (fullPath.includes(`/${defaultLocale}/`)) return fullPath.replace(`/${defaultLocale}/`, "/");
|
|
74
|
+
else if (fullPath.endsWith(`/${defaultLocale}`)) return fullPath.replace(`/${defaultLocale}`, "");
|
|
75
|
+
return null;
|
|
76
|
+
} else {
|
|
77
|
+
if (fullPath.includes(`/${defaultLocale}/`) || fullPath.endsWith(`/${defaultLocale}`)) return null;
|
|
78
|
+
if (fullPath.startsWith(patternHead)) {
|
|
79
|
+
const pathAfterHead = fullPath.slice(patternHead.length);
|
|
80
|
+
if (pathAfterHead) return `${patternHead}${defaultLocale}/${pathAfterHead}`;
|
|
81
|
+
else return `${patternHead.replace(/\/$/, "")}/${defaultLocale}`;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
136
85
|
}
|
|
137
86
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
87
|
+
* Transforms import path for non-default locale processing with hideDefaultLocale=true
|
|
88
|
+
*/
|
|
140
89
|
function transformNonDefaultLocaleImportPathWithHidden(fullPath, patternHead, targetLocale, defaultLocale) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const expectedPathWithDefaultLocale = `${patternHead}${defaultLocale}`;
|
|
148
|
-
if (fullPath.startsWith(`${expectedPathWithDefaultLocale}/`) ||
|
|
149
|
-
fullPath === expectedPathWithDefaultLocale) {
|
|
150
|
-
return fullPath.replace(`${patternHead}${defaultLocale}`, `${patternHead}${targetLocale}`);
|
|
151
|
-
}
|
|
152
|
-
// Handle exact pattern match
|
|
153
|
-
if (fullPath === patternHead.replace(/\/$/, '')) {
|
|
154
|
-
return `${patternHead.replace(/\/$/, '')}/${targetLocale}`;
|
|
155
|
-
}
|
|
156
|
-
// Add target locale to path without any locale
|
|
157
|
-
const pathAfterHead = fullPath.slice(patternHead.length);
|
|
158
|
-
return pathAfterHead
|
|
159
|
-
? `${patternHead}${targetLocale}/${pathAfterHead}`
|
|
160
|
-
: `${patternHead}${targetLocale}`;
|
|
90
|
+
if (fullPath.startsWith(`${patternHead}${targetLocale}/`) || fullPath === `${patternHead}${targetLocale}`) return null;
|
|
91
|
+
const expectedPathWithDefaultLocale = `${patternHead}${defaultLocale}`;
|
|
92
|
+
if (fullPath.startsWith(`${expectedPathWithDefaultLocale}/`) || fullPath === expectedPathWithDefaultLocale) return fullPath.replace(`${patternHead}${defaultLocale}`, `${patternHead}${targetLocale}`);
|
|
93
|
+
if (fullPath === patternHead.replace(/\/$/, "")) return `${patternHead.replace(/\/$/, "")}/${targetLocale}`;
|
|
94
|
+
const pathAfterHead = fullPath.slice(patternHead.length);
|
|
95
|
+
return pathAfterHead ? `${patternHead}${targetLocale}/${pathAfterHead}` : `${patternHead}${targetLocale}`;
|
|
161
96
|
}
|
|
162
97
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
98
|
+
* Transforms import path for non-default locale processing with hideDefaultLocale=false
|
|
99
|
+
*/
|
|
165
100
|
function transformNonDefaultLocaleImportPath(fullPath, patternHead, targetLocale, defaultLocale) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return fullPath.replace(`${patternHead}${defaultLocale}`, `${patternHead}${targetLocale}`);
|
|
177
|
-
}
|
|
178
|
-
else if (fullPath.startsWith(patternHead)) {
|
|
179
|
-
// Add target locale to path that doesn't have any locale
|
|
180
|
-
const pathAfterHead = fullPath.slice(patternHead.length);
|
|
181
|
-
if (pathAfterHead) {
|
|
182
|
-
return `${patternHead}${targetLocale}/${pathAfterHead}`;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
return `${patternHead.replace(/\/$/, '')}/${targetLocale}`;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return null; // Path doesn't match pattern
|
|
101
|
+
const expectedPathWithTarget = `${patternHead}${targetLocale}`;
|
|
102
|
+
if (fullPath.startsWith(`${expectedPathWithTarget}/`) || fullPath === expectedPathWithTarget) return null;
|
|
103
|
+
const expectedPathWithLocale = `${patternHead}${defaultLocale}`;
|
|
104
|
+
if (fullPath.startsWith(`${expectedPathWithLocale}/`) || fullPath === expectedPathWithLocale) return fullPath.replace(`${patternHead}${defaultLocale}`, `${patternHead}${targetLocale}`);
|
|
105
|
+
else if (fullPath.startsWith(patternHead)) {
|
|
106
|
+
const pathAfterHead = fullPath.slice(patternHead.length);
|
|
107
|
+
if (pathAfterHead) return `${patternHead}${targetLocale}/${pathAfterHead}`;
|
|
108
|
+
else return `${patternHead.replace(/\/$/, "")}/${targetLocale}`;
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
189
111
|
}
|
|
190
112
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
function transformImportPath(fullPath, patternHead, targetLocale, defaultLocale, hideDefaultLocale, currentFilePath, projectRoot = process.cwd(),
|
|
194
|
-
rewrites) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
else {
|
|
228
|
-
newPath = transformNonDefaultLocaleImportPath(fullPath, patternHead, targetLocale, defaultLocale);
|
|
229
|
-
}
|
|
230
|
-
if (!newPath)
|
|
231
|
-
return null;
|
|
232
|
-
if (currentFilePath) {
|
|
233
|
-
let resolvedPath;
|
|
234
|
-
if (newPath.startsWith('/')) {
|
|
235
|
-
// Interpret as project-root relative
|
|
236
|
-
resolvedPath = path.join(projectRoot, newPath.replace(/^\//, ''));
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
// Relative to current file
|
|
240
|
-
const currentDir = path.dirname(currentFilePath);
|
|
241
|
-
resolvedPath = path.resolve(currentDir, newPath);
|
|
242
|
-
}
|
|
243
|
-
if (!fs.existsSync(resolvedPath)) {
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return newPath;
|
|
113
|
+
* Main import path transformation function that delegates to specific scenarios
|
|
114
|
+
*/
|
|
115
|
+
function transformImportPath(fullPath, patternHead, targetLocale, defaultLocale, hideDefaultLocale, currentFilePath, projectRoot = process.cwd(), rewrites) {
|
|
116
|
+
if (rewrites && rewrites.length > 0) {
|
|
117
|
+
const localeMap = {
|
|
118
|
+
"[locale]": targetLocale,
|
|
119
|
+
"[defaultLocale]": defaultLocale
|
|
120
|
+
};
|
|
121
|
+
for (const { match, replace } of rewrites) {
|
|
122
|
+
const resolvedMatch = match.replace(/\[locale\]|\[defaultLocale\]/g, (token) => localeMap[token] || token);
|
|
123
|
+
if (fullPath.startsWith(resolvedMatch)) {
|
|
124
|
+
const remainder = fullPath.slice(resolvedMatch.length);
|
|
125
|
+
const resolvedReplace = replace.replace(/\[locale\]|\[defaultLocale\]/g, (token) => localeMap[token] || token);
|
|
126
|
+
let newPath;
|
|
127
|
+
if (resolvedReplace.endsWith("/")) newPath = `${resolvedReplace}${remainder.replace(/^\//, "")}`;
|
|
128
|
+
else if (remainder.startsWith("/")) newPath = `${resolvedReplace}${remainder}`;
|
|
129
|
+
else newPath = `${resolvedReplace}/${remainder}`;
|
|
130
|
+
return newPath;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
let newPath;
|
|
135
|
+
if (targetLocale === defaultLocale) newPath = transformDefaultLocaleImportPath(fullPath, patternHead, defaultLocale, hideDefaultLocale);
|
|
136
|
+
else if (hideDefaultLocale) newPath = transformNonDefaultLocaleImportPathWithHidden(fullPath, patternHead, targetLocale, defaultLocale);
|
|
137
|
+
else newPath = transformNonDefaultLocaleImportPath(fullPath, patternHead, targetLocale, defaultLocale);
|
|
138
|
+
if (!newPath) return null;
|
|
139
|
+
if (currentFilePath) {
|
|
140
|
+
let resolvedPath;
|
|
141
|
+
if (newPath.startsWith("/")) resolvedPath = path$1.join(projectRoot, newPath.replace(/^\//, ""));
|
|
142
|
+
else {
|
|
143
|
+
const currentDir = path$1.dirname(currentFilePath);
|
|
144
|
+
resolvedPath = path$1.resolve(currentDir, newPath);
|
|
145
|
+
}
|
|
146
|
+
if (!fs$1.existsSync(resolvedPath)) return null;
|
|
147
|
+
}
|
|
148
|
+
return newPath;
|
|
248
149
|
}
|
|
249
150
|
/**
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
function transformMdxImports(mdxContent, defaultLocale, targetLocale, hideDefaultLocale, pattern =
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
for (const quote of quotes) {
|
|
315
|
-
// Try both with and without trailing slash
|
|
316
|
-
let startPattern = `${quote}${patternHead}`;
|
|
317
|
-
let startIndex = line.indexOf(startPattern);
|
|
318
|
-
// If pattern has trailing slash but path doesn't, try without slash
|
|
319
|
-
if (startIndex === -1 && patternHead.endsWith('/')) {
|
|
320
|
-
const patternWithoutSlash = patternHead.slice(0, -1);
|
|
321
|
-
startPattern = `${quote}${patternWithoutSlash}`;
|
|
322
|
-
startIndex = line.indexOf(startPattern);
|
|
323
|
-
}
|
|
324
|
-
if (startIndex === -1)
|
|
325
|
-
continue;
|
|
326
|
-
const pathStart = startIndex + 1; // After the quote
|
|
327
|
-
const pathEnd = line.indexOf(quote, pathStart);
|
|
328
|
-
if (pathEnd === -1)
|
|
329
|
-
continue;
|
|
330
|
-
const fullPath = line.slice(pathStart, pathEnd);
|
|
331
|
-
// Transform the import path
|
|
332
|
-
const newPath = transformImportPath(fullPath, patternHead, targetLocale, defaultLocale, hideDefaultLocale, currentFilePath, process.cwd(), options?.docsImportRewrites);
|
|
333
|
-
if (!newPath) {
|
|
334
|
-
continue; // No transformation needed
|
|
335
|
-
}
|
|
336
|
-
// Check exclusions
|
|
337
|
-
if (isImportPathExcluded(fullPath, exclude, defaultLocale)) {
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
|
-
// Apply the transformation to the original content
|
|
341
|
-
// Simply replace the import path with the new path
|
|
342
|
-
content = content.replace(`${quote}${fullPath}${quote}`, `${quote}${newPath}${quote}`);
|
|
343
|
-
transformedImports.push({ originalPath: fullPath, newPath });
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
return {
|
|
350
|
-
content,
|
|
351
|
-
hasChanges: transformedImports.length > 0,
|
|
352
|
-
transformedImports,
|
|
353
|
-
};
|
|
151
|
+
* AST-based transformation for MDX files using remark-mdx
|
|
152
|
+
*/
|
|
153
|
+
function transformMdxImports(mdxContent, defaultLocale, targetLocale, hideDefaultLocale, pattern = "/[locale]", exclude = [], currentFilePath, options) {
|
|
154
|
+
const transformedImports = [];
|
|
155
|
+
if (!pattern.startsWith("/") && !pattern.startsWith(".")) pattern = "/" + pattern;
|
|
156
|
+
const patternHead = pattern.split("[locale]")[0];
|
|
157
|
+
if (targetLocale === defaultLocale) {
|
|
158
|
+
const patternWithoutSlash = patternHead.replace(/\/$/, "");
|
|
159
|
+
if (!mdxContent.includes(patternWithoutSlash)) return {
|
|
160
|
+
content: mdxContent,
|
|
161
|
+
hasChanges: false,
|
|
162
|
+
transformedImports: []
|
|
163
|
+
};
|
|
164
|
+
} else if (!mdxContent.includes(patternHead.replace(/\/$/, ""))) return {
|
|
165
|
+
content: mdxContent,
|
|
166
|
+
hasChanges: false,
|
|
167
|
+
transformedImports: []
|
|
168
|
+
};
|
|
169
|
+
let processedAst;
|
|
170
|
+
try {
|
|
171
|
+
const parseProcessor = unified().use(remarkParse).use(remarkFrontmatter, ["yaml", "toml"]).use(remarkMdx);
|
|
172
|
+
const ast = parseProcessor.parse(mdxContent);
|
|
173
|
+
processedAst = parseProcessor.runSync(ast);
|
|
174
|
+
} catch {
|
|
175
|
+
return transformImportsStringFallback(mdxContent, defaultLocale, targetLocale, hideDefaultLocale, pattern, exclude, currentFilePath, options);
|
|
176
|
+
}
|
|
177
|
+
let content = mdxContent;
|
|
178
|
+
visit(processedAst, "mdxjsEsm", (node) => {
|
|
179
|
+
if (node.value && node.value.includes(patternHead.replace(/\/$/, ""))) node.value.split("\n").forEach((line) => {
|
|
180
|
+
if (!line.trim().startsWith("import ")) return;
|
|
181
|
+
if (!shouldProcessImportPath(line, patternHead, targetLocale, defaultLocale)) return;
|
|
182
|
+
for (const quote of [
|
|
183
|
+
"\"",
|
|
184
|
+
"'",
|
|
185
|
+
"`"
|
|
186
|
+
]) {
|
|
187
|
+
let startPattern = `${quote}${patternHead}`;
|
|
188
|
+
let startIndex = line.indexOf(startPattern);
|
|
189
|
+
if (startIndex === -1 && patternHead.endsWith("/")) {
|
|
190
|
+
startPattern = `${quote}${patternHead.slice(0, -1)}`;
|
|
191
|
+
startIndex = line.indexOf(startPattern);
|
|
192
|
+
}
|
|
193
|
+
if (startIndex === -1) continue;
|
|
194
|
+
const pathStart = startIndex + 1;
|
|
195
|
+
const pathEnd = line.indexOf(quote, pathStart);
|
|
196
|
+
if (pathEnd === -1) continue;
|
|
197
|
+
const fullPath = line.slice(pathStart, pathEnd);
|
|
198
|
+
const newPath = transformImportPath(fullPath, patternHead, targetLocale, defaultLocale, hideDefaultLocale, currentFilePath, process.cwd(), options?.docsImportRewrites);
|
|
199
|
+
if (!newPath) continue;
|
|
200
|
+
if (isImportPathExcluded(fullPath, exclude, defaultLocale)) continue;
|
|
201
|
+
content = content.replace(`${quote}${fullPath}${quote}`, `${quote}${newPath}${quote}`);
|
|
202
|
+
transformedImports.push({
|
|
203
|
+
originalPath: fullPath,
|
|
204
|
+
newPath
|
|
205
|
+
});
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
content,
|
|
212
|
+
hasChanges: transformedImports.length > 0,
|
|
213
|
+
transformedImports
|
|
214
|
+
};
|
|
354
215
|
}
|
|
355
216
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
function transformImportsStringFallback(mdxContent, defaultLocale, targetLocale, hideDefaultLocale, pattern =
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
content,
|
|
385
|
-
hasChanges: transformedImports.length > 0,
|
|
386
|
-
transformedImports,
|
|
387
|
-
};
|
|
217
|
+
* String-based fallback for import localization when MDX parsing fails (e.g., on .md files)
|
|
218
|
+
*/
|
|
219
|
+
function transformImportsStringFallback(mdxContent, defaultLocale, targetLocale, hideDefaultLocale, pattern = "/[locale]", exclude = [], currentFilePath, options) {
|
|
220
|
+
const transformedImports = [];
|
|
221
|
+
if (!pattern.startsWith("/") && !pattern.startsWith(".")) pattern = "/" + pattern;
|
|
222
|
+
const patternHead = pattern.split("[locale]")[0];
|
|
223
|
+
let content = mdxContent;
|
|
224
|
+
const importRegex = /import\s+[^'"]*['"]([^'"]+)['"]\s*;?/g;
|
|
225
|
+
let match;
|
|
226
|
+
while ((match = importRegex.exec(mdxContent)) !== null) {
|
|
227
|
+
const fullMatch = match[0];
|
|
228
|
+
const importPath = match[1];
|
|
229
|
+
if (!shouldProcessImportPath(importPath, patternHead, targetLocale, defaultLocale)) continue;
|
|
230
|
+
if (isImportPathExcluded(importPath, exclude, defaultLocale)) continue;
|
|
231
|
+
const newPath = transformImportPath(importPath, patternHead, targetLocale, defaultLocale, hideDefaultLocale, currentFilePath, process.cwd(), options?.docsImportRewrites);
|
|
232
|
+
if (!newPath) continue;
|
|
233
|
+
const updatedImport = fullMatch.replace(importPath, newPath);
|
|
234
|
+
content = content.replace(fullMatch, updatedImport);
|
|
235
|
+
transformedImports.push({
|
|
236
|
+
originalPath: importPath,
|
|
237
|
+
newPath
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
content,
|
|
242
|
+
hasChanges: transformedImports.length > 0,
|
|
243
|
+
transformedImports
|
|
244
|
+
};
|
|
388
245
|
}
|
|
389
246
|
/**
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
function localizeStaticImportsForFile(file, defaultLocale, targetLocale, hideDefaultLocale, pattern =
|
|
393
|
-
|
|
394
|
-
// For MDX files, use AST-based transformation
|
|
395
|
-
const result = transformMdxImports(file, defaultLocale, targetLocale, hideDefaultLocale, pattern, exclude, currentFilePath, options);
|
|
396
|
-
return result.content;
|
|
247
|
+
* AST-based transformation for MDX files only
|
|
248
|
+
*/
|
|
249
|
+
function localizeStaticImportsForFile(file, defaultLocale, targetLocale, hideDefaultLocale, pattern = "/[locale]", exclude = [], currentFilePath, options) {
|
|
250
|
+
return transformMdxImports(file, defaultLocale, targetLocale, hideDefaultLocale, pattern, exclude, currentFilePath, options).content;
|
|
397
251
|
}
|
|
252
|
+
//#endregion
|
|
253
|
+
export { localizeStaticImports as default };
|
|
254
|
+
|
|
255
|
+
//# sourceMappingURL=localizeStaticImports.js.map
|