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,55 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
publishMap.set(TEMPLATE_FILE_ID, gtPublishValue);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return { files, reactComponents, publishMap };
|
|
1
|
+
import { hashStringSync } from "../../utils/hash.js";
|
|
2
|
+
import { TEMPLATE_FILE_ID, TEMPLATE_FILE_NAME } from "../../utils/constants.js";
|
|
3
|
+
import { logErrorAndExit } from "../../console/logging.js";
|
|
4
|
+
import { invalidConfigurationError } from "../../console/index.js";
|
|
5
|
+
import { isInlineLibrary } from "../../types/libraries.js";
|
|
6
|
+
import { shouldPublishGt } from "../../utils/resolvePublish.js";
|
|
7
|
+
import { aggregateFiles } from "./aggregateFiles.js";
|
|
8
|
+
import { aggregateInlineTranslations } from "../../translation/stage.js";
|
|
9
|
+
//#region src/formats/files/collectFiles.ts
|
|
10
|
+
async function collectFiles(options, settings, library) {
|
|
11
|
+
const { files, publishMap } = await aggregateFiles(settings);
|
|
12
|
+
let reactComponents = 0;
|
|
13
|
+
if (isInlineLibrary(library)) {
|
|
14
|
+
const updates = await aggregateInlineTranslations(options, settings, library);
|
|
15
|
+
if (updates.length > 0) {
|
|
16
|
+
if (!settings.publish && !settings.files?.placeholderPaths.gt) logErrorAndExit(invalidConfigurationError);
|
|
17
|
+
const fileData = {};
|
|
18
|
+
const fileMetadata = {};
|
|
19
|
+
for (const update of updates) {
|
|
20
|
+
const { source, metadata, dataFormat } = update;
|
|
21
|
+
metadata.dataFormat = dataFormat;
|
|
22
|
+
const { hash, id } = metadata;
|
|
23
|
+
if (id) {
|
|
24
|
+
fileData[id] = source;
|
|
25
|
+
fileMetadata[id] = metadata;
|
|
26
|
+
} else if (hash) {
|
|
27
|
+
fileData[hash] = source;
|
|
28
|
+
fileMetadata[hash] = metadata;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
reactComponents = updates.length;
|
|
32
|
+
files.push({
|
|
33
|
+
fileName: TEMPLATE_FILE_NAME,
|
|
34
|
+
content: JSON.stringify(fileData),
|
|
35
|
+
fileFormat: "GTJSON",
|
|
36
|
+
formatMetadata: fileMetadata,
|
|
37
|
+
fileId: TEMPLATE_FILE_ID,
|
|
38
|
+
versionId: hashStringSync(JSON.stringify(Object.keys(fileData).sort())),
|
|
39
|
+
locale: settings.defaultLocale
|
|
40
|
+
});
|
|
41
|
+
const gtPublishValue = shouldPublishGt(settings);
|
|
42
|
+
if (gtPublishValue !== void 0) publishMap.set(TEMPLATE_FILE_ID, gtPublishValue);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
files,
|
|
47
|
+
reactComponents,
|
|
48
|
+
publishMap
|
|
49
|
+
};
|
|
55
50
|
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { collectFiles };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=collectFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectFiles.js","names":[],"sources":["../../../src/formats/files/collectFiles.ts"],"sourcesContent":["import { logErrorAndExit } from '../../console/logging.js';\nimport {\n Settings,\n SupportedLibraries,\n TranslateFlags,\n} from '../../types/index.js';\nimport { invalidConfigurationError } from '../../console/index.js';\nimport { aggregateFiles } from './aggregateFiles.js';\nimport { aggregateInlineTranslations } from '../../translation/stage.js';\nimport type { JsxChildren } from '@generaltranslation/format/types';\nimport type { FileToUpload } from 'generaltranslation/types';\nimport { hashStringSync } from '../../utils/hash.js';\nimport { TEMPLATE_FILE_NAME, TEMPLATE_FILE_ID } from '../../utils/constants.js';\nimport { isInlineLibrary } from '../../types/libraries.js';\nimport { shouldPublishGt } from '../../utils/resolvePublish.js';\n\nexport async function collectFiles(\n options: TranslateFlags,\n settings: Settings,\n library: SupportedLibraries\n): Promise<{\n files: FileToUpload[];\n reactComponents: number;\n publishMap: Map<string, boolean>;\n}> {\n // Aggregate files\n const { files, publishMap } = await aggregateFiles(settings);\n\n // Parse for React components\n let reactComponents = 0;\n if (isInlineLibrary(library)) {\n const updates = await aggregateInlineTranslations(\n options,\n settings,\n library\n );\n if (updates.length > 0) {\n if (!settings.publish && !settings.files?.placeholderPaths.gt) {\n logErrorAndExit(invalidConfigurationError);\n }\n // Convert updates to a file object\n const fileData: Record<string, JsxChildren> = {};\n const fileMetadata: Record<string, unknown> = {};\n // Convert updates to the proper data format\n for (const update of updates) {\n const { source, metadata, dataFormat } = update;\n metadata.dataFormat = dataFormat; // add the data format to the metadata\n const { hash, id } = metadata;\n if (id) {\n fileData[id] = source;\n fileMetadata[id] = metadata;\n } else if (hash) {\n fileData[hash] = source;\n fileMetadata[hash] = metadata;\n }\n }\n reactComponents = updates.length;\n files.push({\n fileName: TEMPLATE_FILE_NAME,\n content: JSON.stringify(fileData),\n fileFormat: 'GTJSON',\n formatMetadata: fileMetadata,\n fileId: TEMPLATE_FILE_ID,\n versionId: hashStringSync(JSON.stringify(Object.keys(fileData).sort())),\n locale: settings.defaultLocale,\n } satisfies FileToUpload);\n // Only add GT JSON to publishMap if there's an explicit publish config\n const gtPublishValue = shouldPublishGt(settings);\n if (gtPublishValue !== undefined) {\n publishMap.set(TEMPLATE_FILE_ID, gtPublishValue);\n }\n }\n }\n return { files, reactComponents, publishMap };\n}\n"],"mappings":";;;;;;;;;AAgBA,eAAsB,aACpB,SACA,UACA,SAKC;CAED,MAAM,EAAE,OAAO,eAAe,MAAM,eAAe,SAAS;CAG5D,IAAI,kBAAkB;AACtB,KAAI,gBAAgB,QAAQ,EAAE;EAC5B,MAAM,UAAU,MAAM,4BACpB,SACA,UACA,QACD;AACD,MAAI,QAAQ,SAAS,GAAG;AACtB,OAAI,CAAC,SAAS,WAAW,CAAC,SAAS,OAAO,iBAAiB,GACzD,iBAAgB,0BAA0B;GAG5C,MAAM,WAAwC,EAAE;GAChD,MAAM,eAAwC,EAAE;AAEhD,QAAK,MAAM,UAAU,SAAS;IAC5B,MAAM,EAAE,QAAQ,UAAU,eAAe;AACzC,aAAS,aAAa;IACtB,MAAM,EAAE,MAAM,OAAO;AACrB,QAAI,IAAI;AACN,cAAS,MAAM;AACf,kBAAa,MAAM;eACV,MAAM;AACf,cAAS,QAAQ;AACjB,kBAAa,QAAQ;;;AAGzB,qBAAkB,QAAQ;AAC1B,SAAM,KAAK;IACT,UAAU;IACV,SAAS,KAAK,UAAU,SAAS;IACjC,YAAY;IACZ,gBAAgB;IAChB,QAAQ;IACR,WAAW,eAAe,KAAK,UAAU,OAAO,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC;IACvE,QAAQ,SAAS;IAClB,CAAwB;GAEzB,MAAM,iBAAiB,gBAAgB,SAAS;AAChD,OAAI,mBAAmB,KAAA,EACrB,YAAW,IAAI,kBAAkB,eAAe;;;AAItD,QAAO;EAAE;EAAO;EAAiB;EAAY"}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
//#region src/formats/files/convertToFileTranslationData.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
fileName: file.fileName,
|
|
19
|
-
},
|
|
20
|
-
]));
|
|
3
|
+
* Convert files to a file version data object
|
|
4
|
+
* @param files - The files to get the version data for
|
|
5
|
+
* @returns The version data for each file
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const { allFiles } = await collectFiles(options, settings, library);
|
|
9
|
+
* if (allFiles.length > 0) {
|
|
10
|
+
* const fileVersionData = getFileVersionData(allFiles);
|
|
11
|
+
* console.log(fileVersionData);
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
function convertToFileTranslationData(files) {
|
|
15
|
+
return Object.fromEntries(files.map((file) => [file.fileId, {
|
|
16
|
+
versionId: file.versionId,
|
|
17
|
+
fileName: file.fileName
|
|
18
|
+
}]));
|
|
21
19
|
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { convertToFileTranslationData };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=convertToFileTranslationData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertToFileTranslationData.js","names":[],"sources":["../../../src/formats/files/convertToFileTranslationData.ts"],"sourcesContent":["import { FileToUpload } from 'generaltranslation/types';\nimport { FileTranslationData } from '../../workflows/download.js';\n\n/**\n * Convert files to a file version data object\n * @param files - The files to get the version data for\n * @returns The version data for each file\n *\n * @example\n * const { allFiles } = await collectFiles(options, settings, library);\n * if (allFiles.length > 0) {\n * const fileVersionData = getFileVersionData(allFiles);\n * console.log(fileVersionData);\n * }\n */\nexport function convertToFileTranslationData(\n files: FileToUpload[]\n): FileTranslationData {\n return Object.fromEntries(\n files.map((file) => [\n file.fileId,\n {\n versionId: file.versionId,\n fileName: file.fileName,\n },\n ])\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAgB,6BACd,OACqB;AACrB,QAAO,OAAO,YACZ,MAAM,KAAK,SAAS,CAClB,KAAK,QACL;EACE,WAAW,KAAK;EAChB,UAAU,KAAK;EAChB,CACF,CAAC,CACH"}
|
|
@@ -1,121 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { replaceLocalePlaceholders } from
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
1
|
+
import { TEMPLATE_FILE_NAME } from "../../utils/constants.js";
|
|
2
|
+
import { getRelative } from "../../fs/findFilepath.js";
|
|
3
|
+
import { SUPPORTED_FILE_EXTENSIONS } from "./supportedFiles.js";
|
|
4
|
+
import { replaceFileExtensionForFormat } from "./transformFormat.js";
|
|
5
|
+
import { resolveLocaleFiles } from "../../fs/config/parseFilesConfig.js";
|
|
6
|
+
import { replaceLocalePlaceholders } from "../utils.js";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { getLocaleProperties } from "@generaltranslation/format";
|
|
9
|
+
//#region src/formats/files/fileMapping.ts
|
|
9
10
|
/**
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
// If no transforms matched, return the original path
|
|
80
|
-
return filePath;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
// transformPath is an object
|
|
85
|
-
const targetLocaleProperties = getLocaleProperties(locale);
|
|
86
|
-
const defaultLocaleProperties = getLocaleProperties(defaultLocale);
|
|
87
|
-
if (!transformPath.replace ||
|
|
88
|
-
typeof transformPath.replace !== 'string') {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
// Replace all locale property placeholders
|
|
92
|
-
const replaceString = replaceLocalePlaceholders(transformPath.replace, targetLocaleProperties);
|
|
93
|
-
translatedFiles = translatedFiles.map((filePath) => {
|
|
94
|
-
let relativePath = getRelative(filePath);
|
|
95
|
-
if (transformPath.match &&
|
|
96
|
-
typeof transformPath.match === 'string') {
|
|
97
|
-
// Replace locale placeholders in the match string using defaultLocale properties
|
|
98
|
-
let matchString = transformPath.match;
|
|
99
|
-
matchString = replaceLocalePlaceholders(matchString, defaultLocaleProperties);
|
|
100
|
-
relativePath = relativePath.replace(new RegExp(matchString, 'g'), replaceString);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
relativePath = replaceString;
|
|
104
|
-
}
|
|
105
|
-
return path.resolve(relativePath);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
for (let i = 0; i < sourcePaths.length; i++) {
|
|
110
|
-
const sourceFile = getRelative(sourcePaths[i]);
|
|
111
|
-
// Format transforms keep the mapped path but rewrite the output suffix.
|
|
112
|
-
const translatedFile = getRelative(transformFormat
|
|
113
|
-
? replaceFileExtensionForFormat(translatedFiles[i], transformFormat)
|
|
114
|
-
: translatedFiles[i]);
|
|
115
|
-
localeMapping[sourceFile] = translatedFile;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
fileMapping[locale] = localeMapping;
|
|
119
|
-
}
|
|
120
|
-
return fileMapping;
|
|
11
|
+
* Creates a mapping between source files and their translated counterparts for each locale
|
|
12
|
+
* @param filePaths - Resolved file paths for different file types
|
|
13
|
+
* @param placeholderPaths - Placeholder paths for translated files
|
|
14
|
+
* @param transformPaths - Transform paths for file naming
|
|
15
|
+
* @param transformFormats - Output file format transforms for translated files
|
|
16
|
+
* @param locales - List of locales to create a mapping for
|
|
17
|
+
* @returns A mapping between source files and their translated counterparts for each locale, in the form of relative paths
|
|
18
|
+
*/
|
|
19
|
+
function createFileMapping(filePaths, placeholderPaths, transformPaths, transformFormats, targetLocales, defaultLocale) {
|
|
20
|
+
const fileMapping = {};
|
|
21
|
+
for (const locale of targetLocales) {
|
|
22
|
+
const translatedPaths = resolveLocaleFiles(placeholderPaths, locale);
|
|
23
|
+
const localeMapping = {};
|
|
24
|
+
if (translatedPaths.gt) localeMapping[TEMPLATE_FILE_NAME] = translatedPaths.gt;
|
|
25
|
+
for (const typeIndex of SUPPORTED_FILE_EXTENSIONS) {
|
|
26
|
+
if (!filePaths[typeIndex] || !translatedPaths[typeIndex]) continue;
|
|
27
|
+
const sourcePaths = filePaths[typeIndex];
|
|
28
|
+
let translatedFiles = translatedPaths[typeIndex];
|
|
29
|
+
if (!translatedFiles) continue;
|
|
30
|
+
const transformPath = transformPaths[typeIndex];
|
|
31
|
+
const transformFormat = transformFormats?.[typeIndex];
|
|
32
|
+
if (transformPath) if (typeof transformPath === "string") translatedFiles = translatedFiles.map((filePath) => {
|
|
33
|
+
const directory = path.dirname(filePath);
|
|
34
|
+
const baseName = path.basename(filePath).split(".")[0];
|
|
35
|
+
const transformedFileName = transformPath.replace("*", baseName).replace("[locale]", locale);
|
|
36
|
+
return path.join(directory, transformedFileName);
|
|
37
|
+
});
|
|
38
|
+
else if (Array.isArray(transformPath)) {
|
|
39
|
+
const targetLocaleProperties = getLocaleProperties(locale);
|
|
40
|
+
const defaultLocaleProperties = getLocaleProperties(defaultLocale);
|
|
41
|
+
translatedFiles = translatedFiles.map((filePath) => {
|
|
42
|
+
const relativePath = getRelative(filePath);
|
|
43
|
+
for (const transform of transformPath) {
|
|
44
|
+
if (!transform.replace || typeof transform.replace !== "string") continue;
|
|
45
|
+
const replaceString = replaceLocalePlaceholders(transform.replace, targetLocaleProperties);
|
|
46
|
+
if (transform.match && typeof transform.match === "string") {
|
|
47
|
+
let matchString = transform.match;
|
|
48
|
+
matchString = replaceLocalePlaceholders(matchString, defaultLocaleProperties);
|
|
49
|
+
if (new RegExp(matchString).test(relativePath)) {
|
|
50
|
+
const transformedPath = relativePath.replace(new RegExp(matchString, "g"), replaceString);
|
|
51
|
+
return path.resolve(transformedPath);
|
|
52
|
+
}
|
|
53
|
+
} else return path.resolve(replaceString);
|
|
54
|
+
}
|
|
55
|
+
return filePath;
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
const targetLocaleProperties = getLocaleProperties(locale);
|
|
59
|
+
const defaultLocaleProperties = getLocaleProperties(defaultLocale);
|
|
60
|
+
if (!transformPath.replace || typeof transformPath.replace !== "string") continue;
|
|
61
|
+
const replaceString = replaceLocalePlaceholders(transformPath.replace, targetLocaleProperties);
|
|
62
|
+
translatedFiles = translatedFiles.map((filePath) => {
|
|
63
|
+
let relativePath = getRelative(filePath);
|
|
64
|
+
if (transformPath.match && typeof transformPath.match === "string") {
|
|
65
|
+
let matchString = transformPath.match;
|
|
66
|
+
matchString = replaceLocalePlaceholders(matchString, defaultLocaleProperties);
|
|
67
|
+
relativePath = relativePath.replace(new RegExp(matchString, "g"), replaceString);
|
|
68
|
+
} else relativePath = replaceString;
|
|
69
|
+
return path.resolve(relativePath);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
for (let i = 0; i < sourcePaths.length; i++) {
|
|
73
|
+
const sourceFile = getRelative(sourcePaths[i]);
|
|
74
|
+
localeMapping[sourceFile] = getRelative(transformFormat ? replaceFileExtensionForFormat(translatedFiles[i], transformFormat) : translatedFiles[i]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
fileMapping[locale] = localeMapping;
|
|
78
|
+
}
|
|
79
|
+
return fileMapping;
|
|
121
80
|
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { createFileMapping };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=fileMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileMapping.js","names":[],"sources":["../../../src/formats/files/fileMapping.ts"],"sourcesContent":["import {\n ResolvedFiles,\n TransformFiles,\n TransformFormats,\n} from '../../types/index.js';\nimport { SUPPORTED_FILE_EXTENSIONS } from '../files/supportedFiles.js';\nimport { resolveLocaleFiles } from '../../fs/config/parseFilesConfig.js';\nimport path from 'node:path';\nimport { getRelative } from '../../fs/findFilepath.js';\nimport { getLocaleProperties } from '@generaltranslation/format';\nimport { replaceLocalePlaceholders } from '../utils.js';\nimport { FileMapping } from '../../types/files.js';\nimport { TEMPLATE_FILE_NAME } from '../../utils/constants.js';\nimport { replaceFileExtensionForFormat } from './transformFormat.js';\n\n/**\n * Creates a mapping between source files and their translated counterparts for each locale\n * @param filePaths - Resolved file paths for different file types\n * @param placeholderPaths - Placeholder paths for translated files\n * @param transformPaths - Transform paths for file naming\n * @param transformFormats - Output file format transforms for translated files\n * @param locales - List of locales to create a mapping for\n * @returns A mapping between source files and their translated counterparts for each locale, in the form of relative paths\n */\nexport function createFileMapping(\n filePaths: ResolvedFiles,\n placeholderPaths: ResolvedFiles,\n transformPaths: TransformFiles,\n transformFormats: TransformFormats,\n targetLocales: string[],\n defaultLocale: string\n): FileMapping {\n const fileMapping: FileMapping = {};\n\n for (const locale of targetLocales) {\n const translatedPaths = resolveLocaleFiles(placeholderPaths, locale);\n const localeMapping: FileMapping[string] = {};\n\n // Process each file type\n\n // Start with GTJSON Template files\n if (translatedPaths.gt) {\n const filepath = translatedPaths.gt;\n localeMapping[TEMPLATE_FILE_NAME] = filepath;\n }\n\n for (const typeIndex of SUPPORTED_FILE_EXTENSIONS) {\n if (!filePaths[typeIndex] || !translatedPaths[typeIndex]) continue;\n\n const sourcePaths = filePaths[typeIndex];\n let translatedFiles = translatedPaths[typeIndex];\n if (!translatedFiles) continue;\n\n const transformPath = transformPaths[typeIndex];\n const transformFormat = transformFormats?.[typeIndex];\n\n if (transformPath) {\n if (typeof transformPath === 'string') {\n translatedFiles = translatedFiles.map((filePath) => {\n const directory = path.dirname(filePath);\n const fileName = path.basename(filePath);\n const baseName = fileName.split('.')[0];\n const transformedFileName = transformPath\n .replace('*', baseName)\n .replace('[locale]', locale);\n return path.join(directory, transformedFileName);\n });\n } else if (Array.isArray(transformPath)) {\n // transformPath is an array of TransformOption objects\n const targetLocaleProperties = getLocaleProperties(locale);\n const defaultLocaleProperties = getLocaleProperties(defaultLocale);\n\n translatedFiles = translatedFiles.map((filePath) => {\n const relativePath = getRelative(filePath);\n\n // Try each transform in order until one matches\n for (const transform of transformPath) {\n if (!transform.replace || typeof transform.replace !== 'string') {\n continue;\n }\n\n // Replace all locale property placeholders in the replace string\n const replaceString = replaceLocalePlaceholders(\n transform.replace,\n targetLocaleProperties\n );\n\n if (transform.match && typeof transform.match === 'string') {\n // Replace locale placeholders in the match string using defaultLocale properties\n let matchString = transform.match;\n matchString = replaceLocalePlaceholders(\n matchString,\n defaultLocaleProperties\n );\n\n const regex = new RegExp(matchString);\n if (regex.test(relativePath)) {\n // This transform matches, apply it and break\n const transformedPath = relativePath.replace(\n new RegExp(matchString, 'g'),\n replaceString\n );\n return path.resolve(transformedPath);\n }\n } else {\n // No match provided: treat as a direct replacement (override)\n return path.resolve(replaceString);\n }\n }\n\n // If no transforms matched, return the original path\n return filePath;\n });\n } else {\n // transformPath is an object\n const targetLocaleProperties = getLocaleProperties(locale);\n const defaultLocaleProperties = getLocaleProperties(defaultLocale);\n if (\n !transformPath.replace ||\n typeof transformPath.replace !== 'string'\n ) {\n continue;\n }\n // Replace all locale property placeholders\n const replaceString = replaceLocalePlaceholders(\n transformPath.replace,\n targetLocaleProperties\n );\n translatedFiles = translatedFiles.map((filePath) => {\n let relativePath = getRelative(filePath);\n if (\n transformPath.match &&\n typeof transformPath.match === 'string'\n ) {\n // Replace locale placeholders in the match string using defaultLocale properties\n let matchString = transformPath.match;\n matchString = replaceLocalePlaceholders(\n matchString,\n defaultLocaleProperties\n );\n\n relativePath = relativePath.replace(\n new RegExp(matchString, 'g'),\n replaceString\n );\n } else {\n relativePath = replaceString;\n }\n return path.resolve(relativePath);\n });\n }\n }\n\n for (let i = 0; i < sourcePaths.length; i++) {\n const sourceFile = getRelative(sourcePaths[i]);\n // Format transforms keep the mapped path but rewrite the output suffix.\n const translatedFile = getRelative(\n transformFormat\n ? replaceFileExtensionForFormat(translatedFiles[i], transformFormat)\n : translatedFiles[i]\n );\n localeMapping[sourceFile] = translatedFile;\n }\n }\n\n fileMapping[locale] = localeMapping;\n }\n\n return fileMapping;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,SAAgB,kBACd,WACA,kBACA,gBACA,kBACA,eACA,eACa;CACb,MAAM,cAA2B,EAAE;AAEnC,MAAK,MAAM,UAAU,eAAe;EAClC,MAAM,kBAAkB,mBAAmB,kBAAkB,OAAO;EACpE,MAAM,gBAAqC,EAAE;AAK7C,MAAI,gBAAgB,GAElB,eAAc,sBADG,gBAAgB;AAInC,OAAK,MAAM,aAAa,2BAA2B;AACjD,OAAI,CAAC,UAAU,cAAc,CAAC,gBAAgB,WAAY;GAE1D,MAAM,cAAc,UAAU;GAC9B,IAAI,kBAAkB,gBAAgB;AACtC,OAAI,CAAC,gBAAiB;GAEtB,MAAM,gBAAgB,eAAe;GACrC,MAAM,kBAAkB,mBAAmB;AAE3C,OAAI,cACF,KAAI,OAAO,kBAAkB,SAC3B,mBAAkB,gBAAgB,KAAK,aAAa;IAClD,MAAM,YAAY,KAAK,QAAQ,SAAS;IAExC,MAAM,WADW,KAAK,SAAS,SACN,CAAC,MAAM,IAAI,CAAC;IACrC,MAAM,sBAAsB,cACzB,QAAQ,KAAK,SAAS,CACtB,QAAQ,YAAY,OAAO;AAC9B,WAAO,KAAK,KAAK,WAAW,oBAAoB;KAChD;YACO,MAAM,QAAQ,cAAc,EAAE;IAEvC,MAAM,yBAAyB,oBAAoB,OAAO;IAC1D,MAAM,0BAA0B,oBAAoB,cAAc;AAElE,sBAAkB,gBAAgB,KAAK,aAAa;KAClD,MAAM,eAAe,YAAY,SAAS;AAG1C,UAAK,MAAM,aAAa,eAAe;AACrC,UAAI,CAAC,UAAU,WAAW,OAAO,UAAU,YAAY,SACrD;MAIF,MAAM,gBAAgB,0BACpB,UAAU,SACV,uBACD;AAED,UAAI,UAAU,SAAS,OAAO,UAAU,UAAU,UAAU;OAE1D,IAAI,cAAc,UAAU;AAC5B,qBAAc,0BACZ,aACA,wBACD;AAGD,WAAI,IADc,OAAO,YAChB,CAAC,KAAK,aAAa,EAAE;QAE5B,MAAM,kBAAkB,aAAa,QACnC,IAAI,OAAO,aAAa,IAAI,EAC5B,cACD;AACD,eAAO,KAAK,QAAQ,gBAAgB;;YAItC,QAAO,KAAK,QAAQ,cAAc;;AAKtC,YAAO;MACP;UACG;IAEL,MAAM,yBAAyB,oBAAoB,OAAO;IAC1D,MAAM,0BAA0B,oBAAoB,cAAc;AAClE,QACE,CAAC,cAAc,WACf,OAAO,cAAc,YAAY,SAEjC;IAGF,MAAM,gBAAgB,0BACpB,cAAc,SACd,uBACD;AACD,sBAAkB,gBAAgB,KAAK,aAAa;KAClD,IAAI,eAAe,YAAY,SAAS;AACxC,SACE,cAAc,SACd,OAAO,cAAc,UAAU,UAC/B;MAEA,IAAI,cAAc,cAAc;AAChC,oBAAc,0BACZ,aACA,wBACD;AAED,qBAAe,aAAa,QAC1B,IAAI,OAAO,aAAa,IAAI,EAC5B,cACD;WAED,gBAAe;AAEjB,YAAO,KAAK,QAAQ,aAAa;MACjC;;AAIN,QAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;IAC3C,MAAM,aAAa,YAAY,YAAY,GAAG;AAO9C,kBAAc,cALS,YACrB,kBACI,8BAA8B,gBAAgB,IAAI,gBAAgB,GAClE,gBAAgB,GAEoB;;;AAI9C,cAAY,UAAU;;AAGxB,QAAO"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { isValidMdx } from
|
|
1
|
+
import { isValidMdx } from "../../../utils/validateMdx.js";
|
|
2
|
+
//#region src/formats/files/preprocess/mdx.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
4
|
+
* Runs MDX-specific preprocessing. Returns a skip reason if the file
|
|
5
|
+
* should be skipped, or null if validation passed.
|
|
6
|
+
*/
|
|
7
|
+
function preprocessMdx(content, filePath, settings) {
|
|
8
|
+
if (!settings.options?.skipFileValidation?.mdx) {
|
|
9
|
+
const validation = isValidMdx(content, filePath);
|
|
10
|
+
if (!validation.isValid) return `MDX file is not AST parsable${validation.error ? `: ${validation.error}` : ""}`;
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
14
13
|
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { preprocessMdx };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=mdx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx.js","names":[],"sources":["../../../../src/formats/files/preprocess/mdx.ts"],"sourcesContent":["import { Settings } from '../../../types/index.js';\nimport { isValidMdx } from '../../../utils/validateMdx.js';\n\n/**\n * Runs MDX-specific preprocessing. Returns a skip reason if the file\n * should be skipped, or null if validation passed.\n */\nexport function preprocessMdx(\n content: string,\n filePath: string,\n settings: Settings\n): string | null {\n if (!settings.options?.skipFileValidation?.mdx) {\n const validation = isValidMdx(content, filePath);\n if (!validation.isValid) {\n return `MDX file is not AST parsable${validation.error ? `: ${validation.error}` : ''}`;\n }\n }\n return null;\n}\n"],"mappings":";;;;;;AAOA,SAAgB,cACd,SACA,UACA,UACe;AACf,KAAI,CAAC,SAAS,SAAS,oBAAoB,KAAK;EAC9C,MAAM,aAAa,WAAW,SAAS,SAAS;AAChD,MAAI,CAAC,WAAW,QACd,QAAO,+BAA+B,WAAW,QAAQ,KAAK,WAAW,UAAU;;AAGvF,QAAO"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { applyMintlifyTitleFallback } from
|
|
2
|
-
import wrapPlainUrls from
|
|
1
|
+
import { applyMintlifyTitleFallback } from "../../../utils/mintlifyTitleFallback.js";
|
|
2
|
+
import wrapPlainUrls from "../../../utils/wrapPlainUrls.js";
|
|
3
|
+
//#region src/formats/files/preprocess/mintlify.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
result = wrapPlainUrls(result);
|
|
14
|
-
return result;
|
|
5
|
+
* Runs all Mintlify-specific preprocessing on file content.
|
|
6
|
+
*/
|
|
7
|
+
function preprocessMintlify(content, filePath, fileType, settings) {
|
|
8
|
+
if (fileType !== "mdx") return content;
|
|
9
|
+
let result = content;
|
|
10
|
+
if (settings.options?.mintlify?.inferTitleFromFilename) result = applyMintlifyTitleFallback(result, filePath, settings.defaultLocale).content;
|
|
11
|
+
result = wrapPlainUrls(result);
|
|
12
|
+
return result;
|
|
15
13
|
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { preprocessMintlify };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=mintlify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mintlify.js","names":[],"sources":["../../../../src/formats/files/preprocess/mintlify.ts"],"sourcesContent":["import { Settings } from '../../../types/index.js';\nimport { applyMintlifyTitleFallback } from '../../../utils/mintlifyTitleFallback.js';\nimport wrapPlainUrls from '../../../utils/wrapPlainUrls.js';\n\n/**\n * Runs all Mintlify-specific preprocessing on file content.\n */\nexport function preprocessMintlify(\n content: string,\n filePath: string,\n fileType: string,\n settings: Settings\n): string {\n if (fileType !== 'mdx') return content;\n\n let result = content;\n\n if (settings.options?.mintlify?.inferTitleFromFilename) {\n result = applyMintlifyTitleFallback(\n result,\n filePath,\n settings.defaultLocale\n ).content;\n }\n\n result = wrapPlainUrls(result);\n\n return result;\n}\n"],"mappings":";;;;;;AAOA,SAAgB,mBACd,SACA,UACA,UACA,UACQ;AACR,KAAI,aAAa,MAAO,QAAO;CAE/B,IAAI,SAAS;AAEb,KAAI,SAAS,SAAS,UAAU,uBAC9B,UAAS,2BACP,QACA,UACA,SAAS,cACV,CAAC;AAGJ,UAAS,cAAc,OAAO;AAE9B,QAAO"}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import sanitizeFileContent from "../../utils/sanitizeFileContent.js";
|
|
2
|
+
import { preprocessMdx } from "./preprocess/mdx.js";
|
|
3
|
+
import { preprocessMintlify } from "./preprocess/mintlify.js";
|
|
4
|
+
//#region src/formats/files/preprocessContent.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (settings.framework === 'mintlify') {
|
|
18
|
-
result = preprocessMintlify(result, filePath, fileType, settings);
|
|
19
|
-
}
|
|
20
|
-
// Universal
|
|
21
|
-
result = sanitizeFileContent(result);
|
|
22
|
-
return result;
|
|
6
|
+
* Preprocesses file content before upload. Returns the processed content,
|
|
7
|
+
* or { skip: reason } if the file should be skipped.
|
|
8
|
+
*/
|
|
9
|
+
function preprocessContent(content, filePath, fileType, settings) {
|
|
10
|
+
let result = content;
|
|
11
|
+
if (fileType === "mdx") {
|
|
12
|
+
const skipReason = preprocessMdx(result, filePath, settings);
|
|
13
|
+
if (skipReason) return { skip: skipReason };
|
|
14
|
+
}
|
|
15
|
+
if (settings.framework === "mintlify") result = preprocessMintlify(result, filePath, fileType, settings);
|
|
16
|
+
result = sanitizeFileContent(result);
|
|
17
|
+
return result;
|
|
23
18
|
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { preprocessContent };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=preprocessContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocessContent.js","names":[],"sources":["../../../src/formats/files/preprocessContent.ts"],"sourcesContent":["import { Settings } from '../../types/index.js';\nimport { preprocessMdx } from './preprocess/mdx.js';\nimport { preprocessMintlify } from './preprocess/mintlify.js';\nimport sanitizeFileContent from '../../utils/sanitizeFileContent.js';\n\n/**\n * Preprocesses file content before upload. Returns the processed content,\n * or { skip: reason } if the file should be skipped.\n */\nexport function preprocessContent(\n content: string,\n filePath: string,\n fileType: string,\n settings: Settings\n): string | { skip: string } {\n let result = content;\n\n // File-type-specific\n if (fileType === 'mdx') {\n const skipReason = preprocessMdx(result, filePath, settings);\n if (skipReason) return { skip: skipReason };\n }\n\n // Framework-specific\n if (settings.framework === 'mintlify') {\n result = preprocessMintlify(result, filePath, fileType, settings);\n }\n\n // Universal\n result = sanitizeFileContent(result);\n\n return result;\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,kBACd,SACA,UACA,UACA,UAC2B;CAC3B,IAAI,SAAS;AAGb,KAAI,aAAa,OAAO;EACtB,MAAM,aAAa,cAAc,QAAQ,UAAU,SAAS;AAC5D,MAAI,WAAY,QAAO,EAAE,MAAM,YAAY;;AAI7C,KAAI,SAAS,cAAc,WACzB,UAAS,mBAAmB,QAAQ,UAAU,UAAU,SAAS;AAInE,UAAS,oBAAoB,OAAO;AAEpC,QAAO"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from
|
|
3
|
-
import
|
|
1
|
+
import { logger } from "../../console/logger.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fs from "fs/promises";
|
|
4
|
+
//#region src/formats/files/save.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
logger.success(`Saved translated ${dataFormat} file to: ${outputPath}`);
|
|
16
|
-
}
|
|
6
|
+
* Saves translated MDX/MD file content to the appropriate location
|
|
7
|
+
*/
|
|
8
|
+
async function saveTranslatedFile(translatedContent, outputDir, fileName, dataFormat, locales) {
|
|
9
|
+
for (const locale of locales) {
|
|
10
|
+
const localeDir = path.join(outputDir, locale);
|
|
11
|
+
await fs.mkdir(localeDir, { recursive: true });
|
|
12
|
+
const outputPath = path.join(localeDir, fileName);
|
|
13
|
+
await fs.writeFile(outputPath, translatedContent);
|
|
14
|
+
logger.success(`Saved translated ${dataFormat} file to: ${outputPath}`);
|
|
15
|
+
}
|
|
17
16
|
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { saveTranslatedFile };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=save.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save.js","names":[],"sources":["../../../src/formats/files/save.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport path from 'node:path';\nimport { DataFormat } from '../../types/data.js';\nimport { logger } from '../../console/logger.js';\n\n/**\n * Saves translated MDX/MD file content to the appropriate location\n */\nexport async function saveTranslatedFile(\n translatedContent: string,\n outputDir: string,\n fileName: string,\n dataFormat: DataFormat,\n locales: string[]\n): Promise<void> {\n // Create locale-specific directories if they don't exist\n for (const locale of locales) {\n const localeDir = path.join(outputDir, locale);\n await fs.mkdir(localeDir, { recursive: true });\n\n // Save the translated file with the appropriate extension\n const outputPath = path.join(localeDir, fileName);\n await fs.writeFile(outputPath, translatedContent);\n logger.success(`Saved translated ${dataFormat} file to: ${outputPath}`);\n }\n}\n"],"mappings":";;;;;;;AAQA,eAAsB,mBACpB,mBACA,WACA,UACA,YACA,SACe;AAEf,MAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,YAAY,KAAK,KAAK,WAAW,OAAO;AAC9C,QAAM,GAAG,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;EAG9C,MAAM,aAAa,KAAK,KAAK,WAAW,SAAS;AACjD,QAAM,GAAG,UAAU,YAAY,kBAAkB;AACjD,SAAO,QAAQ,oBAAoB,WAAW,YAAY,aAAa"}
|