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,117 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fileName: data.fileName,
|
|
39
|
-
}));
|
|
40
|
-
await runPublishWorkflow(files, publishMap, branchData.currentBranch.id, settings);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
import { getRelative } from "../../fs/findFilepath.js";
|
|
2
|
+
import { SUPPORTED_FILE_EXTENSIONS } from "../../formats/files/supportedFiles.js";
|
|
3
|
+
import { hasNonIdentityFileFormatTransformForType } from "../../formats/files/transformFormat.js";
|
|
4
|
+
import { createFileMapping } from "../../formats/files/fileMapping.js";
|
|
5
|
+
import { runPublishWorkflow } from "../../workflows/publish.js";
|
|
6
|
+
import { getDownloadedMeta } from "../../state/recentDownloads.js";
|
|
7
|
+
import { runDownloadWorkflow } from "../../workflows/download.js";
|
|
8
|
+
import copyFile from "../../fs/copyFile.js";
|
|
9
|
+
import flattenJsonFiles from "../../utils/flattenJsonFiles.js";
|
|
10
|
+
import localizeStaticUrls from "../../utils/localizeStaticUrls.js";
|
|
11
|
+
import localizeRelativeAssets from "../../utils/localizeRelativeAssets.js";
|
|
12
|
+
import processAnchorIds from "../../utils/processAnchorIds.js";
|
|
13
|
+
import processOpenApi from "../../utils/processOpenApi.js";
|
|
14
|
+
import localizeStaticImports from "../../utils/localizeStaticImports.js";
|
|
15
|
+
import { persistPostProcessHashes } from "../../utils/persistPostprocessHashes.js";
|
|
16
|
+
//#region src/cli/commands/translate.ts
|
|
17
|
+
async function handleTranslate(options, settings, fileVersionData, jobData, branchData, publishMap) {
|
|
18
|
+
if (fileVersionData) {
|
|
19
|
+
const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } = settings.files;
|
|
20
|
+
const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, transformFormats, settings.locales, settings.defaultLocale);
|
|
21
|
+
await runDownloadWorkflow({
|
|
22
|
+
fileVersionData,
|
|
23
|
+
jobData,
|
|
24
|
+
branchData,
|
|
25
|
+
locales: settings.locales,
|
|
26
|
+
timeoutDuration: options.timeout,
|
|
27
|
+
resolveOutputPath: (sourcePath, locale) => fileMapping[locale]?.[sourcePath] ?? null,
|
|
28
|
+
options: settings,
|
|
29
|
+
forceRetranslation: options.force,
|
|
30
|
+
forceDownload: options.forceDownload || options.force
|
|
31
|
+
});
|
|
32
|
+
if (publishMap && branchData?.currentBranch.id) await runPublishWorkflow(Object.entries(fileVersionData).map(([fileId, data]) => ({
|
|
33
|
+
fileId,
|
|
34
|
+
versionId: data.versionId,
|
|
35
|
+
fileName: data.fileName
|
|
36
|
+
})), publishMap, branchData.currentBranch.id, settings);
|
|
37
|
+
}
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (nonDefaultLocales.length > 0) {
|
|
62
|
-
await localizeRelativeAssets(settings, nonDefaultLocales, postProcessIncludes);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const shouldProcessAnchorIds = settings.options?.experimentalLocalizeStaticUrls ||
|
|
66
|
-
settings.options?.experimentalAddHeaderAnchorIds;
|
|
67
|
-
// Add explicit anchor IDs to translated MDX/MD files to preserve navigation
|
|
68
|
-
// Uses inline {#id} format by default, or div wrapping if experimentalAddHeaderAnchorIds is 'mintlify'
|
|
69
|
-
if (shouldProcessAnchorIds) {
|
|
70
|
-
await processAnchorIds(settings, postProcessIncludes);
|
|
71
|
-
}
|
|
72
|
-
// Localize static imports (import Snippet from /snippets/file.mdx -> import Snippet from /snippets/[locale]/file.mdx)
|
|
73
|
-
if (settings.options?.experimentalLocalizeStaticImports) {
|
|
74
|
-
await localizeStaticImports(settings, postProcessIncludes);
|
|
75
|
-
}
|
|
76
|
-
// Flatten json files into a single file
|
|
77
|
-
if (settings.options?.experimentalFlattenJsonFiles) {
|
|
78
|
-
await flattenJsonFiles(settings, postProcessIncludes);
|
|
79
|
-
}
|
|
80
|
-
// Copy files to the target locale
|
|
81
|
-
if (settings.options?.copyFiles) {
|
|
82
|
-
await copyFile(settings);
|
|
83
|
-
}
|
|
84
|
-
// Record postprocessed content hashes for newly downloaded files
|
|
85
|
-
persistPostProcessHashes(settings, postProcessIncludes, getDownloadedMeta());
|
|
39
|
+
async function postProcessTranslations(settings, includeFiles) {
|
|
40
|
+
const postProcessIncludes = filterPostProcessIncludesForFormatTransforms(settings, includeFiles);
|
|
41
|
+
if (includeFiles && postProcessIncludes?.size === 0) return;
|
|
42
|
+
await processOpenApi(settings, postProcessIncludes);
|
|
43
|
+
if (settings.options?.experimentalLocalizeStaticUrls) {
|
|
44
|
+
const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
|
|
45
|
+
if (nonDefaultLocales.length > 0) await localizeStaticUrls(settings, nonDefaultLocales, postProcessIncludes);
|
|
46
|
+
}
|
|
47
|
+
if (settings.options?.experimentalLocalizeRelativeAssets) {
|
|
48
|
+
const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
|
|
49
|
+
if (nonDefaultLocales.length > 0) await localizeRelativeAssets(settings, nonDefaultLocales, postProcessIncludes);
|
|
50
|
+
}
|
|
51
|
+
if (settings.options?.experimentalLocalizeStaticUrls || settings.options?.experimentalAddHeaderAnchorIds) await processAnchorIds(settings, postProcessIncludes);
|
|
52
|
+
if (settings.options?.experimentalLocalizeStaticImports) await localizeStaticImports(settings, postProcessIncludes);
|
|
53
|
+
if (settings.options?.experimentalFlattenJsonFiles) await flattenJsonFiles(settings, postProcessIncludes);
|
|
54
|
+
if (settings.options?.copyFiles) await copyFile(settings);
|
|
55
|
+
persistPostProcessHashes(settings, postProcessIncludes, getDownloadedMeta());
|
|
86
56
|
}
|
|
87
57
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
58
|
+
* Exclude only outputs whose source file was translated into a different format.
|
|
59
|
+
* @param settings - The settings for the project
|
|
60
|
+
* @param includeFiles - The files to include in the post-processing
|
|
61
|
+
* @returns The files to exclude in the post-processing
|
|
62
|
+
*/
|
|
93
63
|
function filterPostProcessIncludesForFormatTransforms(settings, includeFiles) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } = settings.files;
|
|
107
|
-
const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, transformFormats, settings.locales, settings.defaultLocale);
|
|
108
|
-
const transformedOutputPaths = new Set();
|
|
109
|
-
for (const localeMapping of Object.values(fileMapping)) {
|
|
110
|
-
for (const [sourcePath, outputPath] of Object.entries(localeMapping)) {
|
|
111
|
-
if (transformedSourcePaths.has(sourcePath)) {
|
|
112
|
-
transformedOutputPaths.add(outputPath);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return new Set([...includeFiles].filter((filePath) => !transformedOutputPaths.has(filePath)));
|
|
64
|
+
if (!includeFiles) return includeFiles;
|
|
65
|
+
const transformedSourcePaths = /* @__PURE__ */ new Set();
|
|
66
|
+
for (const fileType of SUPPORTED_FILE_EXTENSIONS) {
|
|
67
|
+
if (!hasNonIdentityFileFormatTransformForType(settings, fileType)) continue;
|
|
68
|
+
for (const sourcePath of settings.files.resolvedPaths[fileType] || []) transformedSourcePaths.add(getRelative(sourcePath));
|
|
69
|
+
}
|
|
70
|
+
if (transformedSourcePaths.size === 0) return includeFiles;
|
|
71
|
+
const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } = settings.files;
|
|
72
|
+
const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, transformFormats, settings.locales, settings.defaultLocale);
|
|
73
|
+
const transformedOutputPaths = /* @__PURE__ */ new Set();
|
|
74
|
+
for (const localeMapping of Object.values(fileMapping)) for (const [sourcePath, outputPath] of Object.entries(localeMapping)) if (transformedSourcePaths.has(sourcePath)) transformedOutputPaths.add(outputPath);
|
|
75
|
+
return new Set([...includeFiles].filter((filePath) => !transformedOutputPaths.has(filePath)));
|
|
117
76
|
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { handleTranslate, postProcessTranslations };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=translate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translate.js","names":[],"sources":["../../../src/cli/commands/translate.ts"],"sourcesContent":["import { EnqueueFilesResult } from 'generaltranslation/types';\nimport { TranslateFlags } from '../../types/index.js';\nimport { Settings } from '../../types/index.js';\nimport {\n FileTranslationData,\n runDownloadWorkflow,\n} from '../../workflows/download.js';\nimport { createFileMapping } from '../../formats/files/fileMapping.js';\nimport copyFile from '../../fs/copyFile.js';\nimport flattenJsonFiles from '../../utils/flattenJsonFiles.js';\nimport localizeStaticUrls from '../../utils/localizeStaticUrls.js';\nimport localizeRelativeAssets from '../../utils/localizeRelativeAssets.js';\nimport processAnchorIds from '../../utils/processAnchorIds.js';\nimport processOpenApi from '../../utils/processOpenApi.js';\nimport localizeStaticImports from '../../utils/localizeStaticImports.js';\nimport { BranchData } from '../../types/branch.js';\nimport { getDownloadedMeta } from '../../state/recentDownloads.js';\nimport { persistPostProcessHashes } from '../../utils/persistPostprocessHashes.js';\nimport { runPublishWorkflow } from '../../workflows/publish.js';\nimport { SUPPORTED_FILE_EXTENSIONS } from '../../formats/files/supportedFiles.js';\nimport { hasNonIdentityFileFormatTransformForType } from '../../formats/files/transformFormat.js';\nimport { getRelative } from '../../fs/findFilepath.js';\n\n// Downloads translations that were completed\nexport async function handleTranslate(\n options: TranslateFlags,\n settings: Settings,\n fileVersionData: FileTranslationData | undefined,\n jobData: EnqueueFilesResult | undefined,\n branchData: BranchData | undefined,\n publishMap?: Map<string, boolean>\n) {\n if (fileVersionData) {\n const {\n resolvedPaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n } = settings.files;\n\n const fileMapping = createFileMapping(\n resolvedPaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n settings.locales,\n settings.defaultLocale\n );\n // Check for remaining translations\n await runDownloadWorkflow({\n fileVersionData: fileVersionData,\n jobData: jobData,\n branchData: branchData,\n locales: settings.locales,\n timeoutDuration: options.timeout,\n resolveOutputPath: (sourcePath, locale) =>\n fileMapping[locale]?.[sourcePath] ?? null,\n options: settings,\n forceRetranslation: options.force,\n forceDownload: options.forceDownload || options.force, // if force is true should also force download\n });\n\n // Publish/unpublish files after translations are downloaded\n if (publishMap && branchData?.currentBranch.id) {\n const files = Object.entries(fileVersionData).map(([fileId, data]) => ({\n fileId,\n versionId: data.versionId,\n fileName: data.fileName,\n }));\n await runPublishWorkflow(\n files,\n publishMap,\n branchData.currentBranch.id,\n settings\n );\n }\n }\n}\n\nexport async function postProcessTranslations(\n settings: Settings,\n includeFiles?: Set<string>\n) {\n const postProcessIncludes = filterPostProcessIncludesForFormatTransforms(\n settings,\n includeFiles\n );\n if (includeFiles && postProcessIncludes?.size === 0) return;\n\n // Mintlify OpenAPI localization (spec routing + validation)\n await processOpenApi(settings, postProcessIncludes);\n\n // Localize static urls (/docs -> /[locale]/docs) and preserve anchor IDs for non-default locales\n // Default locale is processed earlier in the flow in base.ts\n if (settings.options?.experimentalLocalizeStaticUrls) {\n const nonDefaultLocales = settings.locales.filter(\n (locale) => locale !== settings.defaultLocale\n );\n if (nonDefaultLocales.length > 0) {\n await localizeStaticUrls(\n settings,\n nonDefaultLocales,\n postProcessIncludes\n );\n }\n }\n\n // Rewrite relative asset URLs in translated md/mdx files\n if (settings.options?.experimentalLocalizeRelativeAssets) {\n const nonDefaultLocales = settings.locales.filter(\n (locale) => locale !== settings.defaultLocale\n );\n if (nonDefaultLocales.length > 0) {\n await localizeRelativeAssets(\n settings,\n nonDefaultLocales,\n postProcessIncludes\n );\n }\n }\n\n const shouldProcessAnchorIds =\n settings.options?.experimentalLocalizeStaticUrls ||\n settings.options?.experimentalAddHeaderAnchorIds;\n\n // Add explicit anchor IDs to translated MDX/MD files to preserve navigation\n // Uses inline {#id} format by default, or div wrapping if experimentalAddHeaderAnchorIds is 'mintlify'\n if (shouldProcessAnchorIds) {\n await processAnchorIds(settings, postProcessIncludes);\n }\n\n // Localize static imports (import Snippet from /snippets/file.mdx -> import Snippet from /snippets/[locale]/file.mdx)\n if (settings.options?.experimentalLocalizeStaticImports) {\n await localizeStaticImports(settings, postProcessIncludes);\n }\n\n // Flatten json files into a single file\n if (settings.options?.experimentalFlattenJsonFiles) {\n await flattenJsonFiles(settings, postProcessIncludes);\n }\n\n // Copy files to the target locale\n if (settings.options?.copyFiles) {\n await copyFile(settings);\n }\n\n // Record postprocessed content hashes for newly downloaded files\n persistPostProcessHashes(settings, postProcessIncludes, getDownloadedMeta());\n}\n\n/**\n * Exclude only outputs whose source file was translated into a different format.\n * @param settings - The settings for the project\n * @param includeFiles - The files to include in the post-processing\n * @returns The files to exclude in the post-processing\n */\nfunction filterPostProcessIncludesForFormatTransforms(\n settings: Settings,\n includeFiles?: Set<string>\n): Set<string> | undefined {\n if (!includeFiles) return includeFiles;\n\n const transformedSourcePaths = new Set<string>();\n for (const fileType of SUPPORTED_FILE_EXTENSIONS) {\n if (!hasNonIdentityFileFormatTransformForType(settings, fileType)) continue;\n\n for (const sourcePath of settings.files.resolvedPaths[fileType] || []) {\n transformedSourcePaths.add(getRelative(sourcePath));\n }\n }\n if (transformedSourcePaths.size === 0) return includeFiles;\n\n const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } =\n settings.files;\n const fileMapping = createFileMapping(\n resolvedPaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n settings.locales,\n settings.defaultLocale\n );\n\n const transformedOutputPaths = new Set<string>();\n for (const localeMapping of Object.values(fileMapping)) {\n for (const [sourcePath, outputPath] of Object.entries(localeMapping)) {\n if (transformedSourcePaths.has(sourcePath)) {\n transformedOutputPaths.add(outputPath);\n }\n }\n }\n\n return new Set(\n [...includeFiles].filter(\n (filePath) => !transformedOutputPaths.has(filePath)\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,eAAsB,gBACpB,SACA,UACA,iBACA,SACA,YACA,YACA;AACA,KAAI,iBAAiB;EACnB,MAAM,EACJ,eACA,kBACA,gBACA,qBACE,SAAS;EAEb,MAAM,cAAc,kBAClB,eACA,kBACA,gBACA,kBACA,SAAS,SACT,SAAS,cACV;AAED,QAAM,oBAAoB;GACP;GACR;GACG;GACZ,SAAS,SAAS;GAClB,iBAAiB,QAAQ;GACzB,oBAAoB,YAAY,WAC9B,YAAY,UAAU,eAAe;GACvC,SAAS;GACT,oBAAoB,QAAQ;GAC5B,eAAe,QAAQ,iBAAiB,QAAQ;GACjD,CAAC;AAGF,MAAI,cAAc,YAAY,cAAc,GAM1C,OAAM,mBALQ,OAAO,QAAQ,gBAAgB,CAAC,KAAK,CAAC,QAAQ,WAAW;GACrE;GACA,WAAW,KAAK;GAChB,UAAU,KAAK;GAChB,EAEM,EACL,YACA,WAAW,cAAc,IACzB,SACD;;;AAKP,eAAsB,wBACpB,UACA,cACA;CACA,MAAM,sBAAsB,6CAC1B,UACA,aACD;AACD,KAAI,gBAAgB,qBAAqB,SAAS,EAAG;AAGrD,OAAM,eAAe,UAAU,oBAAoB;AAInD,KAAI,SAAS,SAAS,gCAAgC;EACpD,MAAM,oBAAoB,SAAS,QAAQ,QACxC,WAAW,WAAW,SAAS,cACjC;AACD,MAAI,kBAAkB,SAAS,EAC7B,OAAM,mBACJ,UACA,mBACA,oBACD;;AAKL,KAAI,SAAS,SAAS,oCAAoC;EACxD,MAAM,oBAAoB,SAAS,QAAQ,QACxC,WAAW,WAAW,SAAS,cACjC;AACD,MAAI,kBAAkB,SAAS,EAC7B,OAAM,uBACJ,UACA,mBACA,oBACD;;AAUL,KALE,SAAS,SAAS,kCAClB,SAAS,SAAS,+BAKlB,OAAM,iBAAiB,UAAU,oBAAoB;AAIvD,KAAI,SAAS,SAAS,kCACpB,OAAM,sBAAsB,UAAU,oBAAoB;AAI5D,KAAI,SAAS,SAAS,6BACpB,OAAM,iBAAiB,UAAU,oBAAoB;AAIvD,KAAI,SAAS,SAAS,UACpB,OAAM,SAAS,SAAS;AAI1B,0BAAyB,UAAU,qBAAqB,mBAAmB,CAAC;;;;;;;;AAS9E,SAAS,6CACP,UACA,cACyB;AACzB,KAAI,CAAC,aAAc,QAAO;CAE1B,MAAM,yCAAyB,IAAI,KAAa;AAChD,MAAK,MAAM,YAAY,2BAA2B;AAChD,MAAI,CAAC,yCAAyC,UAAU,SAAS,CAAE;AAEnE,OAAK,MAAM,cAAc,SAAS,MAAM,cAAc,aAAa,EAAE,CACnE,wBAAuB,IAAI,YAAY,WAAW,CAAC;;AAGvD,KAAI,uBAAuB,SAAS,EAAG,QAAO;CAE9C,MAAM,EAAE,eAAe,kBAAkB,gBAAgB,qBACvD,SAAS;CACX,MAAM,cAAc,kBAClB,eACA,kBACA,gBACA,kBACA,SAAS,SACT,SAAS,cACV;CAED,MAAM,yCAAyB,IAAI,KAAa;AAChD,MAAK,MAAM,iBAAiB,OAAO,OAAO,YAAY,CACpD,MAAK,MAAM,CAAC,YAAY,eAAe,OAAO,QAAQ,cAAc,CAClE,KAAI,uBAAuB,IAAI,WAAW,CACxC,wBAAuB,IAAI,WAAW;AAK5C,QAAO,IAAI,IACT,CAAC,GAAG,aAAa,CAAC,QACf,aAAa,CAAC,uBAAuB,IAAI,SAAS,CACpD,CACF"}
|
|
@@ -1,215 +1,187 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getRelative, readFile } from
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import { validateJsonSchema } from
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { hasValidCredentials } from
|
|
17
|
-
import { buildPublishMap } from
|
|
18
|
-
import { runPublishWorkflow } from
|
|
19
|
-
import {
|
|
20
|
-
|
|
1
|
+
import { logger } from "../../console/logger.js";
|
|
2
|
+
import { hashStringSync } from "../../utils/hash.js";
|
|
3
|
+
import { exitSync, logErrorAndExit } from "../../console/logging.js";
|
|
4
|
+
import { getRelative, readFile } from "../../fs/findFilepath.js";
|
|
5
|
+
import { noDefaultLocaleError, noSupportedFormatError } from "../../console/index.js";
|
|
6
|
+
import { SUPPORTED_FILE_EXTENSIONS } from "../../formats/files/supportedFiles.js";
|
|
7
|
+
import { getTransformFormatProperty } from "../../formats/files/transformFormat.js";
|
|
8
|
+
import sanitizeFileContent from "../../utils/sanitizeFileContent.js";
|
|
9
|
+
import { validateJsonSchema } from "../../formats/json/utils.js";
|
|
10
|
+
import { parseJson } from "../../formats/json/parseJson.js";
|
|
11
|
+
import { extractJson } from "../../formats/json/extractJson.js";
|
|
12
|
+
import { resolveMintlifyRefs, shouldResolveRefs } from "../../utils/resolveMintlifyRefs.js";
|
|
13
|
+
import { runUploadFilesWorkflow } from "../../workflows/upload.js";
|
|
14
|
+
import { createFileMapping } from "../../formats/files/fileMapping.js";
|
|
15
|
+
import parseYaml from "../../formats/yaml/parseYaml.js";
|
|
16
|
+
import { hasValidCredentials } from "./utils/validation.js";
|
|
17
|
+
import { buildPublishMap } from "../../utils/resolvePublish.js";
|
|
18
|
+
import { runPublishWorkflow } from "../../workflows/publish.js";
|
|
19
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
20
|
+
//#region src/cli/commands/upload.ts
|
|
21
|
+
const SUPPORTED_DATA_FORMATS = [
|
|
22
|
+
"JSX",
|
|
23
|
+
"ICU",
|
|
24
|
+
"I18NEXT"
|
|
25
|
+
];
|
|
21
26
|
/**
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
// Non-composite: look for separate translation files
|
|
182
|
-
const translatedFileName = fileMapping[locale]?.[file.fileName];
|
|
183
|
-
if (translatedFileName && existsSync(translatedFileName)) {
|
|
184
|
-
const translatedContent = readFileSync(translatedFileName, 'utf8');
|
|
185
|
-
translations.push({
|
|
186
|
-
content: translatedContent,
|
|
187
|
-
fileName: translatedFileName,
|
|
188
|
-
fileFormat: file.transformFormat ?? file.fileFormat,
|
|
189
|
-
dataFormat: file.dataFormat,
|
|
190
|
-
locale,
|
|
191
|
-
fileId: file.fileId,
|
|
192
|
-
versionId: file.versionId,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return {
|
|
198
|
-
source: sourceFile,
|
|
199
|
-
translations,
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
try {
|
|
203
|
-
// Send all files in a single API call
|
|
204
|
-
const { branchData } = await runUploadFilesWorkflow({
|
|
205
|
-
files: uploadData,
|
|
206
|
-
options: settings,
|
|
207
|
-
});
|
|
208
|
-
// Publish files to CDN if publish config exists
|
|
209
|
-
const publishMap = buildPublishMap(filePaths, settings);
|
|
210
|
-
await runPublishWorkflow(allFiles, publishMap, branchData.currentBranch.id, settings);
|
|
211
|
-
}
|
|
212
|
-
catch (error) {
|
|
213
|
-
logErrorAndExit(`Error uploading files: ${error}`);
|
|
214
|
-
}
|
|
27
|
+
* Sends multiple files to the API for translation
|
|
28
|
+
* @param filePaths - Resolved file paths for different file types
|
|
29
|
+
* @param placeholderPaths - Placeholder paths for translated files
|
|
30
|
+
* @param transformPaths - Transform paths for file naming
|
|
31
|
+
* @param dataFormat - Format of the data within the files
|
|
32
|
+
* @param settings - Translation options including API settings
|
|
33
|
+
* @returns Promise that resolves when translation is complete
|
|
34
|
+
*/
|
|
35
|
+
async function upload(filePaths, placeholderPaths, transformPaths, dataFormat = "JSX", settings) {
|
|
36
|
+
const allFiles = [];
|
|
37
|
+
const additionalOptions = settings.options || {};
|
|
38
|
+
const compositeJsonFiles = /* @__PURE__ */ new Map();
|
|
39
|
+
if (filePaths.json) {
|
|
40
|
+
if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) logErrorAndExit(noSupportedFormatError);
|
|
41
|
+
const jsonFiles = filePaths.json.map((filePath) => {
|
|
42
|
+
const content = readFile(filePath);
|
|
43
|
+
let contentForParsing = content;
|
|
44
|
+
if (shouldResolveRefs(filePath, additionalOptions)) try {
|
|
45
|
+
const { resolved } = resolveMintlifyRefs(JSON.parse(content), filePath);
|
|
46
|
+
contentForParsing = JSON.stringify(resolved, null, 2);
|
|
47
|
+
} catch {}
|
|
48
|
+
const parsedJson = parseJson(contentForParsing, filePath, additionalOptions, settings.defaultLocale);
|
|
49
|
+
const relativePath = getRelative(filePath);
|
|
50
|
+
if (validateJsonSchema(additionalOptions, filePath)?.composite) compositeJsonFiles.set(relativePath, {
|
|
51
|
+
filePath,
|
|
52
|
+
content
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
content: parsedJson,
|
|
56
|
+
fileName: relativePath,
|
|
57
|
+
fileFormat: "JSON",
|
|
58
|
+
...getTransformFormatProperty(settings, "json"),
|
|
59
|
+
dataFormat,
|
|
60
|
+
locale: settings.defaultLocale,
|
|
61
|
+
fileId: hashStringSync(relativePath),
|
|
62
|
+
versionId: hashStringSync(parsedJson)
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
allFiles.push(...jsonFiles);
|
|
66
|
+
}
|
|
67
|
+
if (filePaths.yaml) {
|
|
68
|
+
if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) logErrorAndExit(noSupportedFormatError);
|
|
69
|
+
const yamlFiles = filePaths.yaml.map((filePath) => {
|
|
70
|
+
const { content: parsedYaml, fileFormat } = parseYaml(readFile(filePath), filePath, additionalOptions);
|
|
71
|
+
const relativePath = getRelative(filePath);
|
|
72
|
+
return {
|
|
73
|
+
content: parsedYaml,
|
|
74
|
+
fileName: relativePath,
|
|
75
|
+
fileFormat,
|
|
76
|
+
...getTransformFormatProperty(settings, "yaml"),
|
|
77
|
+
dataFormat,
|
|
78
|
+
locale: settings.defaultLocale,
|
|
79
|
+
fileId: hashStringSync(relativePath),
|
|
80
|
+
versionId: hashStringSync(parsedYaml)
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
allFiles.push(...yamlFiles);
|
|
84
|
+
}
|
|
85
|
+
if (filePaths.twilioContentJson) {
|
|
86
|
+
const twilioContentJsonFiles = filePaths.twilioContentJson.map((filePath) => {
|
|
87
|
+
const parsedJson = parseJson(readFile(filePath), filePath, additionalOptions, settings.defaultLocale);
|
|
88
|
+
const relativePath = getRelative(filePath);
|
|
89
|
+
return {
|
|
90
|
+
content: parsedJson,
|
|
91
|
+
fileName: relativePath,
|
|
92
|
+
fileFormat: "TWILIO_CONTENT_JSON",
|
|
93
|
+
...getTransformFormatProperty(settings, "twilioContentJson"),
|
|
94
|
+
dataFormat: "STRING",
|
|
95
|
+
locale: settings.defaultLocale,
|
|
96
|
+
fileId: hashStringSync(relativePath),
|
|
97
|
+
versionId: hashStringSync(parsedJson)
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
allFiles.push(...twilioContentJsonFiles);
|
|
101
|
+
}
|
|
102
|
+
for (const fileType of SUPPORTED_FILE_EXTENSIONS) {
|
|
103
|
+
if (fileType === "json" || fileType === "yaml" || fileType === "twilioContentJson") continue;
|
|
104
|
+
if (filePaths[fileType]) {
|
|
105
|
+
const files = filePaths[fileType].map((filePath) => {
|
|
106
|
+
const sanitizedContent = sanitizeFileContent(readFile(filePath));
|
|
107
|
+
const relativePath = getRelative(filePath);
|
|
108
|
+
return {
|
|
109
|
+
content: sanitizedContent,
|
|
110
|
+
fileName: relativePath,
|
|
111
|
+
fileFormat: fileType.toUpperCase(),
|
|
112
|
+
...getTransformFormatProperty(settings, fileType),
|
|
113
|
+
dataFormat,
|
|
114
|
+
locale: settings.defaultLocale,
|
|
115
|
+
fileId: hashStringSync(relativePath),
|
|
116
|
+
versionId: hashStringSync(sanitizedContent)
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
allFiles.push(...files);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (allFiles.length === 0) {
|
|
123
|
+
logger.error("No files to upload were found. Check your configuration and try again.");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!settings.defaultLocale) return logErrorAndExit(noDefaultLocaleError);
|
|
127
|
+
if (!hasValidCredentials(settings)) return exitSync(1);
|
|
128
|
+
const locales = settings.locales || [];
|
|
129
|
+
const fileMapping = createFileMapping(filePaths, placeholderPaths, transformPaths, settings.files?.transformFormats || {}, locales, settings.defaultLocale);
|
|
130
|
+
const uploadData = allFiles.map((file) => {
|
|
131
|
+
const sourceFile = {
|
|
132
|
+
content: file.content,
|
|
133
|
+
fileName: file.fileName,
|
|
134
|
+
fileFormat: file.fileFormat,
|
|
135
|
+
transformFormat: file.transformFormat,
|
|
136
|
+
dataFormat: file.dataFormat,
|
|
137
|
+
locale: file.locale,
|
|
138
|
+
fileId: file.fileId,
|
|
139
|
+
versionId: file.versionId
|
|
140
|
+
};
|
|
141
|
+
const translations = [];
|
|
142
|
+
const compositeInfo = compositeJsonFiles.get(file.fileName);
|
|
143
|
+
for (const locale of locales) if (compositeInfo) {
|
|
144
|
+
const extracted = extractJson(compositeInfo.content, compositeInfo.filePath, additionalOptions, locale, settings.defaultLocale);
|
|
145
|
+
if (extracted) translations.push({
|
|
146
|
+
content: extracted,
|
|
147
|
+
fileName: file.fileName,
|
|
148
|
+
fileFormat: file.transformFormat ?? file.fileFormat,
|
|
149
|
+
dataFormat: file.dataFormat,
|
|
150
|
+
locale,
|
|
151
|
+
fileId: file.fileId,
|
|
152
|
+
versionId: file.versionId
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
const translatedFileName = fileMapping[locale]?.[file.fileName];
|
|
156
|
+
if (translatedFileName && existsSync(translatedFileName)) {
|
|
157
|
+
const translatedContent = readFileSync(translatedFileName, "utf8");
|
|
158
|
+
translations.push({
|
|
159
|
+
content: translatedContent,
|
|
160
|
+
fileName: translatedFileName,
|
|
161
|
+
fileFormat: file.transformFormat ?? file.fileFormat,
|
|
162
|
+
dataFormat: file.dataFormat,
|
|
163
|
+
locale,
|
|
164
|
+
fileId: file.fileId,
|
|
165
|
+
versionId: file.versionId
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
source: sourceFile,
|
|
171
|
+
translations
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
try {
|
|
175
|
+
const { branchData } = await runUploadFilesWorkflow({
|
|
176
|
+
files: uploadData,
|
|
177
|
+
options: settings
|
|
178
|
+
});
|
|
179
|
+
await runPublishWorkflow(allFiles, buildPublishMap(filePaths, settings), branchData.currentBranch.id, settings);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
logErrorAndExit(`Error uploading files: ${error}`);
|
|
182
|
+
}
|
|
215
183
|
}
|
|
184
|
+
//#endregion
|
|
185
|
+
export { upload };
|
|
186
|
+
|
|
187
|
+
//# sourceMappingURL=upload.js.map
|