gt 2.14.35 → 2.14.36
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 +16 -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.js +104 -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
package/dist/cli/base.js
CHANGED
|
@@ -1,500 +1,385 @@
|
|
|
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
|
-
import { retrieveCredentials, setCredentials } from
|
|
17
|
-
import {
|
|
18
|
-
import { upload } from
|
|
19
|
-
import { attachSharedFlags, attachTranslateFlags } from
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { displayTranslateSummary } from
|
|
27
|
-
import
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
message: 'What type of API key would you like to generate?',
|
|
234
|
-
options: [
|
|
235
|
-
{ value: 'development', label: 'Development' },
|
|
236
|
-
{ value: 'production', label: 'Production' },
|
|
237
|
-
{ value: 'all', label: 'Both' },
|
|
238
|
-
],
|
|
239
|
-
defaultValue: 'all',
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
if (options.keyType !== 'development' &&
|
|
244
|
-
options.keyType !== 'production' &&
|
|
245
|
-
options.keyType !== 'all') {
|
|
246
|
-
logErrorAndExit('Invalid key type, must be development, production, or all');
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
await this.handleLoginCommand(options);
|
|
250
|
-
logger.endCommand(`Done! ${options.keyType} keys have been generated and saved to your .env.local file.`);
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
setupInitCommand() {
|
|
254
|
-
this.program
|
|
255
|
-
.command('init')
|
|
256
|
-
.description('Run the setup wizard to configure your project for General Translation')
|
|
257
|
-
.option('--src <paths...>', "Space-separated list of glob patterns containing the app's source code, by default 'src/**/*.{js,jsx,ts,tsx}' 'app/**/*.{js,jsx,ts,tsx}' 'pages/**/*.{js,jsx,ts,tsx}' 'components/**/*.{js,jsx,ts,tsx}'")
|
|
258
|
-
.option('-c, --config <path>', 'Filepath to config file, by default gt.config.json', findFilepath(['gt.config.json']))
|
|
259
|
-
.action(async (options) => {
|
|
260
|
-
const settings = await generateSettings(options);
|
|
261
|
-
displayHeader('Running setup wizard...');
|
|
262
|
-
const framework = await detectFramework();
|
|
263
|
-
const useAgent = await (async () => {
|
|
264
|
-
let useAgentMessage;
|
|
265
|
-
if (framework.name === 'mintlify') {
|
|
266
|
-
useAgentMessage = `Mintlify project detected. Would you like to connect to GitHub so that the Locadex AI Agent can translate your project automatically?`;
|
|
267
|
-
}
|
|
268
|
-
if (framework.name === 'next-app') {
|
|
269
|
-
useAgentMessage = `Next.js App Router detected. Would you like to connect to GitHub so that the Locadex AI Agent can set up your project automatically?`;
|
|
270
|
-
}
|
|
271
|
-
if (useAgentMessage) {
|
|
272
|
-
return await promptConfirm({
|
|
273
|
-
message: useAgentMessage,
|
|
274
|
-
defaultValue: false,
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
return false;
|
|
278
|
-
})();
|
|
279
|
-
if (useAgent) {
|
|
280
|
-
await setupLocadex(settings);
|
|
281
|
-
logger.endCommand('Once installed, Locadex will open a PR to your repository. See the docs for more information: https://generaltranslation.com/docs/locadex');
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
// Get framework display info for the defaults message
|
|
285
|
-
const frameworkDisplayName = framework.type === 'react'
|
|
286
|
-
? getFrameworkDisplayName(framework)
|
|
287
|
-
: null;
|
|
288
|
-
const library = framework.type === 'react'
|
|
289
|
-
? getReactFrameworkLibrary(framework)
|
|
290
|
-
: null;
|
|
291
|
-
// Build defaults description based on detected framework
|
|
292
|
-
const defaultTranslationsDir = framework.name === 'vite'
|
|
293
|
-
? DEFAULT_VITE_TRANSLATIONS_DIR
|
|
294
|
-
: DEFAULT_TRANSLATIONS_DIR;
|
|
295
|
-
const defaultsDescription = framework.type === 'react'
|
|
296
|
-
? `${library} & GTProvider, ${frameworkDisplayName}, Files saved locally in ${defaultTranslationsDir}`
|
|
297
|
-
: `Files saved locally in ${defaultTranslationsDir}`;
|
|
298
|
-
// Ask if user wants to use defaults
|
|
299
|
-
const useDefaults = await promptConfirm({
|
|
300
|
-
message: `Would you like to use the recommended General Translation defaults? ${chalk.dim(`(${defaultsDescription})`)}`,
|
|
301
|
-
defaultValue: true,
|
|
302
|
-
});
|
|
303
|
-
let ranReactSetup = false;
|
|
304
|
-
// so that people can run init in non-js projects
|
|
305
|
-
if (framework.type === 'react') {
|
|
306
|
-
const wrap = useDefaults
|
|
307
|
-
? true
|
|
308
|
-
: await promptConfirm({
|
|
309
|
-
message: `Would you like to install ${library} and add the GTProvider? See the docs for more information: https://generaltranslation.com/docs/react/tutorials/quickstart`,
|
|
310
|
-
defaultValue: true,
|
|
311
|
-
});
|
|
312
|
-
if (wrap) {
|
|
313
|
-
logger.info(`${chalk.yellow('[EXPERIMENTAL]')} Configuring project...`);
|
|
314
|
-
await handleSetupReactCommand(options, framework, useDefaults);
|
|
315
|
-
logger.endCommand(`Done! Since this wizard is experimental, please review the changes and make modifications as needed.
|
|
1
|
+
import { logger } from "../console/logger.js";
|
|
2
|
+
import { isPackageInstalled, searchForPackageJson } from "../utils/packageJson.js";
|
|
3
|
+
import { DEFAULT_TRANSLATIONS_DIR, DEFAULT_VITE_TRANSLATIONS_DIR } from "../utils/constants.js";
|
|
4
|
+
import { parseGlobPatterns } from "../console/promptParsing.js";
|
|
5
|
+
import { displayHeader, logErrorAndExit, promptConfirm, promptGlobPatterns, promptMultiSelect, promptSelect, promptText } from "../console/logging.js";
|
|
6
|
+
import findFilepath from "../fs/findFilepath.js";
|
|
7
|
+
import { INLINE_LIBRARIES } from "../types/libraries.js";
|
|
8
|
+
import { FILE_EXT_TO_EXT_LABEL } from "../formats/files/supportedFiles.js";
|
|
9
|
+
import { generateSettings } from "../config/generateSettings.js";
|
|
10
|
+
import { createOrUpdateConfig } from "../fs/config/setupConfig.js";
|
|
11
|
+
import { getPackageManager } from "../utils/packageManager.js";
|
|
12
|
+
import { installPackage } from "../utils/installPackage.js";
|
|
13
|
+
import { getFrameworkDisplayName, getReactFrameworkLibrary } from "../setup/frameworkUtils.js";
|
|
14
|
+
import { handleSetupReactCommand } from "../setup/wizard.js";
|
|
15
|
+
import { getDesiredLocales } from "../setup/userInput.js";
|
|
16
|
+
import { areCredentialsSet, retrieveCredentials, setCredentials } from "../utils/credentials.js";
|
|
17
|
+
import { clearWarnings } from "../state/translateWarnings.js";
|
|
18
|
+
import { upload } from "./commands/upload.js";
|
|
19
|
+
import { attachSharedFlags, attachTranslateFlags } from "./flags.js";
|
|
20
|
+
import updateConfig from "../fs/config/updateConfig.js";
|
|
21
|
+
import { handleStage } from "./commands/stage.js";
|
|
22
|
+
import { handleSetupProject } from "./commands/setupProject.js";
|
|
23
|
+
import { clearDownloaded, getNeedsPostprocessing } from "../state/recentDownloads.js";
|
|
24
|
+
import { handleDownload } from "./commands/download.js";
|
|
25
|
+
import { handleTranslate, postProcessTranslations } from "./commands/translate.js";
|
|
26
|
+
import { displayTranslateSummary } from "../console/displayTranslateSummary.js";
|
|
27
|
+
import { createLoadTranslationsFile } from "../fs/createLoadTranslationsFile.js";
|
|
28
|
+
import { saveLocalEdits } from "../api/saveLocalEdits.js";
|
|
29
|
+
import processSharedStaticAssets, { mirrorAssetsToLocales } from "../utils/sharedStaticAssets.js";
|
|
30
|
+
import { setupLocadex } from "../locadex/setupFlow.js";
|
|
31
|
+
import { detectFramework } from "../setup/detectFramework.js";
|
|
32
|
+
import { handleEnqueue } from "./commands/enqueue.js";
|
|
33
|
+
import { splitMintlifyLanguageRefs } from "../utils/splitMintlifyLanguageRefs.js";
|
|
34
|
+
import chalk from "chalk";
|
|
35
|
+
import path from "node:path";
|
|
36
|
+
import fs from "node:fs";
|
|
37
|
+
//#region src/cli/base.ts
|
|
38
|
+
var BaseCLI = class {
|
|
39
|
+
library;
|
|
40
|
+
additionalModules;
|
|
41
|
+
program;
|
|
42
|
+
constructor(program, library, additionalModules) {
|
|
43
|
+
this.program = program;
|
|
44
|
+
this.library = library;
|
|
45
|
+
this.additionalModules = additionalModules || [];
|
|
46
|
+
this.program.option("--skip-version-check", "Skip the monorepo GT package version consistency check");
|
|
47
|
+
this.setupInitCommand();
|
|
48
|
+
this.setupConfigureCommand();
|
|
49
|
+
this.setupUploadCommand();
|
|
50
|
+
this.setupLoginCommand();
|
|
51
|
+
this.setupSendDiffsCommand();
|
|
52
|
+
}
|
|
53
|
+
init() {
|
|
54
|
+
this.setupSetupProjectCommand();
|
|
55
|
+
this.setupStageCommand();
|
|
56
|
+
this.setupTranslateCommand();
|
|
57
|
+
this.setupDownloadCommand();
|
|
58
|
+
this.setupEnqueueCommand();
|
|
59
|
+
}
|
|
60
|
+
execute() {
|
|
61
|
+
if (process.argv.length <= 2) process.argv.push("init");
|
|
62
|
+
}
|
|
63
|
+
setupSetupProjectCommand() {
|
|
64
|
+
attachTranslateFlags(this.program.command("setup").description("Upload source files and setup the project for translation")).action(async (initOptions) => {
|
|
65
|
+
displayHeader("Uploading source files and setting up project...");
|
|
66
|
+
await this.handleSetupProject(initOptions);
|
|
67
|
+
logger.endCommand("Done!");
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
setupStageCommand() {
|
|
71
|
+
attachTranslateFlags(this.program.command("stage").description("Submits the project to the General Translation API for translation. Translations created using this command will require human approval.")).action(async (initOptions) => {
|
|
72
|
+
displayHeader("Staging project for translation with approval required...");
|
|
73
|
+
await this.handleStage(initOptions);
|
|
74
|
+
logger.endCommand("Done!");
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Enqueues translations for a given set of files
|
|
79
|
+
* @param initOptions - The options for the command
|
|
80
|
+
* @returns The results of the command
|
|
81
|
+
*/
|
|
82
|
+
setupEnqueueCommand() {
|
|
83
|
+
attachTranslateFlags(this.program.command("enqueue").description("Enqueues translations for a given set of files")).action(async (initOptions) => {
|
|
84
|
+
displayHeader("Enqueuing translations...");
|
|
85
|
+
await this.handleEnqueue(initOptions);
|
|
86
|
+
logger.endCommand("Done!");
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Downloads translations that were originally staged
|
|
91
|
+
* @param initOptions - The options for the command
|
|
92
|
+
* @returns The results of the command
|
|
93
|
+
*/
|
|
94
|
+
setupDownloadCommand() {
|
|
95
|
+
attachTranslateFlags(this.program.command("download").description("Download translations that were originally staged")).action(async (initOptions) => {
|
|
96
|
+
displayHeader("Downloading translations...");
|
|
97
|
+
await this.handleDownload(initOptions);
|
|
98
|
+
logger.endCommand("Done!");
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
setupTranslateCommand() {
|
|
102
|
+
attachTranslateFlags(this.program.command("translate").description("Translate your project using General Translation")).action(async (initOptions) => {
|
|
103
|
+
displayHeader("Starting translation...");
|
|
104
|
+
await this.handleTranslate(initOptions);
|
|
105
|
+
logger.endCommand("Done!");
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
setupSendDiffsCommand() {
|
|
109
|
+
attachSharedFlags(this.program.command("save-local").description("Save local edits for all configured files by sending diffs (no translation enqueued)")).option("--publish", "Publish translations to the CDN", false).action(async (initOptions) => {
|
|
110
|
+
displayHeader("Saving local edits...");
|
|
111
|
+
await saveLocalEdits(await generateSettings(initOptions, void 0, { requireConfig: true }));
|
|
112
|
+
logger.endCommand("Saved local edits");
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async handleSetupProject(initOptions) {
|
|
116
|
+
const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
|
|
117
|
+
await processSharedStaticAssets(settings);
|
|
118
|
+
await handleSetupProject(initOptions, settings, this.library);
|
|
119
|
+
}
|
|
120
|
+
async handleStage(initOptions) {
|
|
121
|
+
const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
|
|
122
|
+
await processSharedStaticAssets(settings);
|
|
123
|
+
if (!settings.stageTranslations) {
|
|
124
|
+
settings.stageTranslations = true;
|
|
125
|
+
await updateConfig(settings.config, { stageTranslations: true });
|
|
126
|
+
}
|
|
127
|
+
await handleStage(initOptions, settings, this.library, true);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Enqueues translations for a given set of files
|
|
131
|
+
* @param initOptions - The options for the command
|
|
132
|
+
* @returns The results of the command
|
|
133
|
+
*/
|
|
134
|
+
async handleEnqueue(initOptions) {
|
|
135
|
+
await handleEnqueue(initOptions, await generateSettings(initOptions, void 0, { requireConfig: true }), this.library);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Downloads translations that were originally staged
|
|
139
|
+
* @param initOptions - The options for the command
|
|
140
|
+
* @returns The results of the command
|
|
141
|
+
*/
|
|
142
|
+
async handleDownload(initOptions) {
|
|
143
|
+
await handleDownload(initOptions, await generateSettings(initOptions, void 0, { requireConfig: true }), this.library);
|
|
144
|
+
}
|
|
145
|
+
async handleTranslate(initOptions) {
|
|
146
|
+
const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
|
|
147
|
+
await processSharedStaticAssets(settings);
|
|
148
|
+
if (!settings.stageTranslations) {
|
|
149
|
+
const results = await handleStage(initOptions, settings, this.library, false);
|
|
150
|
+
if (results) await handleTranslate(initOptions, settings, results.fileVersionData, results.jobData, results.branchData, results.publishMap);
|
|
151
|
+
} else await handleDownload(initOptions, settings, this.library);
|
|
152
|
+
const include = getNeedsPostprocessing();
|
|
153
|
+
if (include.size > 0) await postProcessTranslations(settings, include);
|
|
154
|
+
await splitMintlifyLanguageRefs(settings);
|
|
155
|
+
await mirrorAssetsToLocales(settings);
|
|
156
|
+
clearDownloaded();
|
|
157
|
+
displayTranslateSummary();
|
|
158
|
+
clearWarnings();
|
|
159
|
+
}
|
|
160
|
+
setupUploadCommand() {
|
|
161
|
+
attachTranslateFlags(this.program.command("upload").description("Upload source files and translations to the General Translation platform")).action(async (initOptions) => {
|
|
162
|
+
displayHeader("Starting upload...");
|
|
163
|
+
const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
|
|
164
|
+
const options = {
|
|
165
|
+
...initOptions,
|
|
166
|
+
...settings
|
|
167
|
+
};
|
|
168
|
+
await this.handleUploadCommand(options);
|
|
169
|
+
logger.endCommand("Done!");
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
setupLoginCommand() {
|
|
173
|
+
this.program.command("auth").description("Generate General Translation API keys and project ID").option("-c, --config <path>", "Filepath to config file, by default gt.config.json", findFilepath(["gt.config.json"])).option("-t, --key-type <type>", "Type of key to generate, production | development | all").action(async (options) => {
|
|
174
|
+
displayHeader("Authenticating with General Translation...");
|
|
175
|
+
if (!options.keyType) options.keyType = await promptSelect({
|
|
176
|
+
message: "What type of API key would you like to generate?",
|
|
177
|
+
options: [
|
|
178
|
+
{
|
|
179
|
+
value: "development",
|
|
180
|
+
label: "Development"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
value: "production",
|
|
184
|
+
label: "Production"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
value: "all",
|
|
188
|
+
label: "Both"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
defaultValue: "all"
|
|
192
|
+
});
|
|
193
|
+
else if (options.keyType !== "development" && options.keyType !== "production" && options.keyType !== "all") logErrorAndExit("Invalid key type, must be development, production, or all");
|
|
194
|
+
await this.handleLoginCommand(options);
|
|
195
|
+
logger.endCommand(`Done! ${options.keyType} keys have been generated and saved to your .env.local file.`);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
setupInitCommand() {
|
|
199
|
+
this.program.command("init").description("Run the setup wizard to configure your project for General Translation").option("--src <paths...>", "Space-separated list of glob patterns containing the app's source code, by default 'src/**/*.{js,jsx,ts,tsx}' 'app/**/*.{js,jsx,ts,tsx}' 'pages/**/*.{js,jsx,ts,tsx}' 'components/**/*.{js,jsx,ts,tsx}'").option("-c, --config <path>", "Filepath to config file, by default gt.config.json", findFilepath(["gt.config.json"])).action(async (options) => {
|
|
200
|
+
const settings = await generateSettings(options);
|
|
201
|
+
displayHeader("Running setup wizard...");
|
|
202
|
+
const framework = await detectFramework();
|
|
203
|
+
if (await (async () => {
|
|
204
|
+
let useAgentMessage;
|
|
205
|
+
if (framework.name === "mintlify") useAgentMessage = `Mintlify project detected. Would you like to connect to GitHub so that the Locadex AI Agent can translate your project automatically?`;
|
|
206
|
+
if (framework.name === "next-app") useAgentMessage = `Next.js App Router detected. Would you like to connect to GitHub so that the Locadex AI Agent can set up your project automatically?`;
|
|
207
|
+
if (useAgentMessage) return await promptConfirm({
|
|
208
|
+
message: useAgentMessage,
|
|
209
|
+
defaultValue: false
|
|
210
|
+
});
|
|
211
|
+
return false;
|
|
212
|
+
})()) {
|
|
213
|
+
await setupLocadex(settings);
|
|
214
|
+
logger.endCommand("Once installed, Locadex will open a PR to your repository. See the docs for more information: https://generaltranslation.com/docs/locadex");
|
|
215
|
+
} else {
|
|
216
|
+
const frameworkDisplayName = framework.type === "react" ? getFrameworkDisplayName(framework) : null;
|
|
217
|
+
const library = framework.type === "react" ? getReactFrameworkLibrary(framework) : null;
|
|
218
|
+
const defaultTranslationsDir = framework.name === "vite" ? DEFAULT_VITE_TRANSLATIONS_DIR : DEFAULT_TRANSLATIONS_DIR;
|
|
219
|
+
const defaultsDescription = framework.type === "react" ? `${library} & GTProvider, ${frameworkDisplayName}, Files saved locally in ${defaultTranslationsDir}` : `Files saved locally in ${defaultTranslationsDir}`;
|
|
220
|
+
const useDefaults = await promptConfirm({
|
|
221
|
+
message: `Would you like to use the recommended General Translation defaults? ${chalk.dim(`(${defaultsDescription})`)}`,
|
|
222
|
+
defaultValue: true
|
|
223
|
+
});
|
|
224
|
+
let ranReactSetup = false;
|
|
225
|
+
if (framework.type === "react") {
|
|
226
|
+
if (useDefaults ? true : await promptConfirm({
|
|
227
|
+
message: `Would you like to install ${library} and add the GTProvider? See the docs for more information: https://generaltranslation.com/docs/react/tutorials/quickstart`,
|
|
228
|
+
defaultValue: true
|
|
229
|
+
})) {
|
|
230
|
+
logger.info(`${chalk.yellow("[EXPERIMENTAL]")} Configuring project...`);
|
|
231
|
+
await handleSetupReactCommand(options, framework, useDefaults);
|
|
232
|
+
logger.endCommand(`Done! Since this wizard is experimental, please review the changes and make modifications as needed.
|
|
316
233
|
\nNext step: start internationalizing! See the docs for more information: https://generaltranslation.com/docs/react/tutorials/quickstart`);
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
const isUsingGT = ranReactSetup || gtInstalled;
|
|
374
|
-
// Ask where the translations are stored
|
|
375
|
-
const usingCDN = await (async () => {
|
|
376
|
-
if (!isUsingGT)
|
|
377
|
-
return false;
|
|
378
|
-
if (useDefaults)
|
|
379
|
-
return false; // Default to local
|
|
380
|
-
const selectedValue = await promptSelect({
|
|
381
|
-
message: `Would you like to save translation files locally or use the General Translation CDN to store them?`,
|
|
382
|
-
options: [
|
|
383
|
-
{ value: 'local', label: 'Save locally' },
|
|
384
|
-
{ value: 'cdn', label: 'Use CDN' },
|
|
385
|
-
],
|
|
386
|
-
defaultValue: 'local',
|
|
387
|
-
});
|
|
388
|
-
return selectedValue === 'cdn';
|
|
389
|
-
})();
|
|
390
|
-
const defaultTranslationsDir = isVite
|
|
391
|
-
? DEFAULT_VITE_TRANSLATIONS_DIR
|
|
392
|
-
: DEFAULT_TRANSLATIONS_DIR;
|
|
393
|
-
// Ask where the translations are stored
|
|
394
|
-
const translationsDir = isUsingGT && !usingCDN
|
|
395
|
-
? useDefaults
|
|
396
|
-
? defaultTranslationsDir
|
|
397
|
-
: await promptText({
|
|
398
|
-
message: 'What is the path to the directory where you would like to store your translation files?',
|
|
399
|
-
defaultValue: defaultTranslationsDir,
|
|
400
|
-
})
|
|
401
|
-
: null;
|
|
402
|
-
// Determine final translations directory with fallback
|
|
403
|
-
const finalTranslationsDir = translationsDir?.trim() || defaultTranslationsDir;
|
|
404
|
-
if (isUsingGT && !usingCDN) {
|
|
405
|
-
// Create loadTranslations.js file for local translations
|
|
406
|
-
await createLoadTranslationsFile(process.cwd(), finalTranslationsDir, locales);
|
|
407
|
-
logger.message(`Created ${chalk.cyan('loadTranslations.js')} file for local translations.
|
|
234
|
+
ranReactSetup = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (ranReactSetup) logger.startCommand("Setting up project config...");
|
|
238
|
+
await this.handleInitCommand(ranReactSetup, useDefaults, framework.name === "vite");
|
|
239
|
+
logger.endCommand("Done! Check out our docs for more information on how to use General Translation: https://generaltranslation.com/docs");
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
setupConfigureCommand() {
|
|
244
|
+
this.program.command("configure").description("Configure your project for General Translation. This will create a gt.config.json file in your codebase.").action(async () => {
|
|
245
|
+
displayHeader("Configuring project...");
|
|
246
|
+
logger.info("Welcome! This tool will help you configure your gt.config.json file. See the docs: https://generaltranslation.com/docs/cli/reference/config for more information.");
|
|
247
|
+
const framework = await detectFramework();
|
|
248
|
+
await this.handleInitCommand(false, false, framework.name === "vite");
|
|
249
|
+
logger.endCommand("Done! Make sure you have an API key and project ID to use General Translation. Get them on the dashboard: https://generaltranslation.com/dashboard");
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
async handleUploadCommand(settings) {
|
|
253
|
+
let dataFormat;
|
|
254
|
+
if (this.library === "next-intl") dataFormat = "ICU";
|
|
255
|
+
else if (this.library === "i18next") if (this.additionalModules.includes("i18next-icu")) dataFormat = "ICU";
|
|
256
|
+
else dataFormat = "I18NEXT";
|
|
257
|
+
else dataFormat = "JSX";
|
|
258
|
+
if (!settings.files) return;
|
|
259
|
+
const { resolvedPaths: sourceFiles, placeholderPaths, transformPaths } = settings.files;
|
|
260
|
+
await upload(sourceFiles, placeholderPaths, transformPaths, dataFormat, settings);
|
|
261
|
+
}
|
|
262
|
+
async handleInitCommand(ranReactSetup, useDefaults = false, isVite = false) {
|
|
263
|
+
const { defaultLocale, locales } = await getDesiredLocales();
|
|
264
|
+
const packageJson = await searchForPackageJson();
|
|
265
|
+
const gtInstalled = !!packageJson && INLINE_LIBRARIES.some((lib) => isPackageInstalled(lib, packageJson));
|
|
266
|
+
const isUsingGT = ranReactSetup || gtInstalled;
|
|
267
|
+
const usingCDN = await (async () => {
|
|
268
|
+
if (!isUsingGT) return false;
|
|
269
|
+
if (useDefaults) return false;
|
|
270
|
+
return await promptSelect({
|
|
271
|
+
message: `Would you like to save translation files locally or use the General Translation CDN to store them?`,
|
|
272
|
+
options: [{
|
|
273
|
+
value: "local",
|
|
274
|
+
label: "Save locally"
|
|
275
|
+
}, {
|
|
276
|
+
value: "cdn",
|
|
277
|
+
label: "Use CDN"
|
|
278
|
+
}],
|
|
279
|
+
defaultValue: "local"
|
|
280
|
+
}) === "cdn";
|
|
281
|
+
})();
|
|
282
|
+
const defaultTranslationsDir = isVite ? DEFAULT_VITE_TRANSLATIONS_DIR : DEFAULT_TRANSLATIONS_DIR;
|
|
283
|
+
const finalTranslationsDir = (isUsingGT && !usingCDN ? useDefaults ? defaultTranslationsDir : await promptText({
|
|
284
|
+
message: "What is the path to the directory where you would like to store your translation files?",
|
|
285
|
+
defaultValue: defaultTranslationsDir
|
|
286
|
+
}) : null)?.trim() || defaultTranslationsDir;
|
|
287
|
+
if (isUsingGT && !usingCDN) {
|
|
288
|
+
await createLoadTranslationsFile(process.cwd(), finalTranslationsDir, locales);
|
|
289
|
+
logger.message(`Created ${chalk.cyan("loadTranslations.js")} file for local translations.
|
|
408
290
|
Make sure to add this function to your app configuration.
|
|
409
291
|
See https://generaltranslation.com/en/docs/next/guides/local-tx`);
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
292
|
+
}
|
|
293
|
+
const message = !isUsingGT ? "What is the format of your language resource files? Select as many as applicable.\nAdditionally, you can translate any other files you have in your project." : `Do you have any additional files in this project to translate? For example, Markdown files for docs. ${chalk.dim("(To continue without selecting press Enter)")}`;
|
|
294
|
+
const fileExtensions = useDefaults && isUsingGT ? [] : await promptMultiSelect({
|
|
295
|
+
message,
|
|
296
|
+
options: [
|
|
297
|
+
{
|
|
298
|
+
value: "json",
|
|
299
|
+
label: FILE_EXT_TO_EXT_LABEL.json
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
value: "md",
|
|
303
|
+
label: FILE_EXT_TO_EXT_LABEL.md
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
value: "mdx",
|
|
307
|
+
label: FILE_EXT_TO_EXT_LABEL.mdx
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
value: "ts",
|
|
311
|
+
label: FILE_EXT_TO_EXT_LABEL.ts
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
value: "js",
|
|
315
|
+
label: FILE_EXT_TO_EXT_LABEL.js
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
value: "yaml",
|
|
319
|
+
label: FILE_EXT_TO_EXT_LABEL.yaml
|
|
320
|
+
}
|
|
321
|
+
],
|
|
322
|
+
required: !isUsingGT
|
|
323
|
+
});
|
|
324
|
+
const files = {};
|
|
325
|
+
for (const fileExtension of fileExtensions) {
|
|
326
|
+
const label = FILE_EXT_TO_EXT_LABEL[fileExtension];
|
|
327
|
+
files[fileExtension] = { include: parseGlobPatterns(await promptGlobPatterns({
|
|
328
|
+
label,
|
|
329
|
+
message: `${chalk.cyan(FILE_EXT_TO_EXT_LABEL[fileExtension])}: Enter a space-separated list of glob patterns matching the location of the ${FILE_EXT_TO_EXT_LABEL[fileExtension]} files you would like to translate.\nMake sure to include [locale] in the patterns.\nSee https://generaltranslation.com/docs/cli/reference/config#include for more information.`,
|
|
330
|
+
defaultValue: `./**/[locale]/*.${fileExtension}`
|
|
331
|
+
})) };
|
|
332
|
+
}
|
|
333
|
+
if (isUsingGT && !usingCDN) files.gt = { output: path.join(finalTranslationsDir, `[locale].json`) };
|
|
334
|
+
let configFilepath = "gt.config.json";
|
|
335
|
+
if (fs.existsSync("src/gt.config.json")) configFilepath = "src/gt.config.json";
|
|
336
|
+
await createOrUpdateConfig(configFilepath, {
|
|
337
|
+
defaultLocale,
|
|
338
|
+
locales,
|
|
339
|
+
files: Object.keys(files).length > 0 ? files : void 0,
|
|
340
|
+
publish: isUsingGT && usingCDN
|
|
341
|
+
});
|
|
342
|
+
logger.success(`Edit ${chalk.cyan(configFilepath)} to customize your translation setup. Docs: https://generaltranslation.com/docs/cli/reference/config`);
|
|
343
|
+
if (!(packageJson ? isPackageInstalled("gt", packageJson, true, true) : true)) {
|
|
344
|
+
const packageManager = await getPackageManager();
|
|
345
|
+
const spinner = logger.createSpinner();
|
|
346
|
+
spinner.start(`Installing gt as a dev dependency with ${packageManager.name}...`);
|
|
347
|
+
await installPackage("gt", packageManager, true);
|
|
348
|
+
spinner.stop(chalk.green("Installed gt."));
|
|
349
|
+
}
|
|
350
|
+
if (!areCredentialsSet()) {
|
|
351
|
+
if (useDefaults ? true : await promptConfirm({
|
|
352
|
+
message: "Would you like the wizard to automatically generate API keys and a project ID for you?",
|
|
353
|
+
defaultValue: true
|
|
354
|
+
})) {
|
|
355
|
+
const settings = await generateSettings({});
|
|
356
|
+
await setCredentials(await retrieveCredentials(settings, useDefaults ? "all" : await promptSelect({
|
|
357
|
+
message: "What type of API key would you like to generate?",
|
|
358
|
+
options: [
|
|
359
|
+
{
|
|
360
|
+
value: "development",
|
|
361
|
+
label: "Development"
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
value: "production",
|
|
365
|
+
label: "Production"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
value: "all",
|
|
369
|
+
label: "Both"
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
defaultValue: "all"
|
|
373
|
+
})), settings.framework);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
async handleLoginCommand(options) {
|
|
378
|
+
const settings = await generateSettings({ config: options.config });
|
|
379
|
+
await setCredentials(await retrieveCredentials(settings, options.keyType || "all"), settings.framework);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
//#endregion
|
|
383
|
+
export { BaseCLI };
|
|
384
|
+
|
|
385
|
+
//# sourceMappingURL=base.js.map
|