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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","names":[],"sources":["../../../src/cli/commands/upload.ts"],"sourcesContent":["import {\n noSupportedFormatError,\n noDefaultLocaleError,\n} from '../../console/index.js';\nimport { exitSync, logErrorAndExit } from '../../console/logging.js';\nimport { logger } from '../../console/logger.js';\nimport { getRelative, readFile } from '../../fs/findFilepath.js';\nimport { ResolvedFiles, Settings, TransformFiles } from '../../types/index.js';\nimport { FileFormat, DataFormat } from '../../types/data.js';\nimport { SUPPORTED_FILE_EXTENSIONS } from '../../formats/files/supportedFiles.js';\nimport { UploadOptions } from '../base.js';\nimport sanitizeFileContent from '../../utils/sanitizeFileContent.js';\nimport { parseJson } from '../../formats/json/parseJson.js';\nimport { extractJson } from '../../formats/json/extractJson.js';\nimport { validateJsonSchema } from '../../formats/json/utils.js';\nimport {\n resolveMintlifyRefs,\n shouldResolveRefs,\n} from '../../utils/resolveMintlifyRefs.js';\nimport { runUploadFilesWorkflow } from '../../workflows/upload.js';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createFileMapping } from '../../formats/files/fileMapping.js';\nimport parseYaml from '../../formats/yaml/parseYaml.js';\nimport type { FileToUpload } from 'generaltranslation/types';\nimport { hashStringSync } from '../../utils/hash.js';\nimport { hasValidCredentials } from './utils/validation.js';\nimport { buildPublishMap } from '../../utils/resolvePublish.js';\nimport { runPublishWorkflow } from '../../workflows/publish.js';\nimport { getTransformFormatProperty } from '../../formats/files/transformFormat.js';\n\nconst SUPPORTED_DATA_FORMATS = ['JSX', 'ICU', 'I18NEXT'];\n\n/**\n * Sends multiple files to the API for translation\n * @param filePaths - Resolved file paths for different file types\n * @param placeholderPaths - Placeholder paths for translated files\n * @param transformPaths - Transform paths for file naming\n * @param dataFormat - Format of the data within the files\n * @param settings - Translation options including API settings\n * @returns Promise that resolves when translation is complete\n */\nexport async function upload(\n filePaths: ResolvedFiles,\n placeholderPaths: ResolvedFiles,\n transformPaths: TransformFiles,\n dataFormat: DataFormat = 'JSX',\n settings: Settings & UploadOptions\n): Promise<void> {\n // Collect all files to translate\n const allFiles: FileToUpload[] = [];\n const additionalOptions = settings.options || {};\n const compositeJsonFiles = new Map<\n string,\n { filePath: string; content: string }\n >();\n\n // Process JSON files\n if (filePaths.json) {\n if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) {\n logErrorAndExit(noSupportedFormatError);\n }\n\n const jsonFiles = filePaths.json.map((filePath) => {\n const content = readFile(filePath);\n\n // Resolve $ref before parsing if configured\n let contentForParsing = content;\n if (shouldResolveRefs(filePath, additionalOptions)) {\n try {\n const json = JSON.parse(content);\n const { resolved } = resolveMintlifyRefs(json, filePath);\n contentForParsing = JSON.stringify(resolved, null, 2);\n } catch {\n // JSON parse errors are handled below by parseJson\n }\n }\n\n const parsedJson = parseJson(\n contentForParsing,\n filePath,\n additionalOptions,\n settings.defaultLocale\n );\n\n const relativePath = getRelative(filePath);\n\n const jsonSchema = validateJsonSchema(additionalOptions, filePath);\n if (jsonSchema?.composite) {\n compositeJsonFiles.set(relativePath, { filePath, content });\n }\n\n return {\n content: parsedJson,\n fileName: relativePath,\n fileFormat: 'JSON' as FileFormat,\n ...getTransformFormatProperty(settings, 'json'),\n dataFormat,\n locale: settings.defaultLocale,\n fileId: hashStringSync(relativePath),\n versionId: hashStringSync(parsedJson),\n } satisfies FileToUpload;\n });\n allFiles.push(...jsonFiles);\n }\n\n // Process YAML files\n if (filePaths.yaml) {\n if (!SUPPORTED_DATA_FORMATS.includes(dataFormat)) {\n logErrorAndExit(noSupportedFormatError);\n }\n\n const yamlFiles = filePaths.yaml.map((filePath) => {\n const content = readFile(filePath);\n const { content: parsedYaml, fileFormat } = parseYaml(\n content,\n filePath,\n additionalOptions\n );\n\n const relativePath = getRelative(filePath);\n return {\n content: parsedYaml,\n fileName: relativePath,\n fileFormat,\n ...getTransformFormatProperty(settings, 'yaml'),\n dataFormat,\n locale: settings.defaultLocale,\n fileId: hashStringSync(relativePath),\n versionId: hashStringSync(parsedYaml),\n } satisfies FileToUpload;\n });\n allFiles.push(...yamlFiles);\n }\n\n // Process Twilio Content JSON files\n if (filePaths.twilioContentJson) {\n const twilioContentJsonFiles = filePaths.twilioContentJson.map(\n (filePath) => {\n const content = readFile(filePath);\n\n const parsedJson = parseJson(\n content,\n filePath,\n additionalOptions,\n settings.defaultLocale\n );\n\n const relativePath = getRelative(filePath);\n\n return {\n content: parsedJson,\n fileName: relativePath,\n fileFormat: 'TWILIO_CONTENT_JSON' as const,\n ...getTransformFormatProperty(settings, 'twilioContentJson'),\n dataFormat: 'STRING' as const,\n locale: settings.defaultLocale,\n fileId: hashStringSync(relativePath),\n versionId: hashStringSync(parsedJson),\n } satisfies FileToUpload;\n }\n );\n allFiles.push(...twilioContentJsonFiles);\n }\n\n for (const fileType of SUPPORTED_FILE_EXTENSIONS) {\n if (\n fileType === 'json' ||\n fileType === 'yaml' ||\n fileType === 'twilioContentJson'\n )\n continue;\n if (filePaths[fileType]) {\n const files = filePaths[fileType].map((filePath) => {\n const content = readFile(filePath);\n const sanitizedContent = sanitizeFileContent(content);\n const relativePath = getRelative(filePath);\n return {\n content: sanitizedContent,\n fileName: relativePath,\n fileFormat: fileType.toUpperCase() as FileFormat,\n ...getTransformFormatProperty(settings, fileType),\n dataFormat,\n locale: settings.defaultLocale,\n fileId: hashStringSync(relativePath),\n versionId: hashStringSync(sanitizedContent),\n } satisfies FileToUpload;\n });\n allFiles.push(...files);\n }\n }\n\n if (allFiles.length === 0) {\n logger.error(\n 'No files to upload were found. Check your configuration and try again.'\n );\n return;\n }\n\n if (!settings.defaultLocale) {\n return logErrorAndExit(noDefaultLocaleError);\n }\n if (!hasValidCredentials(settings)) return exitSync(1);\n\n const locales = settings.locales || [];\n // Create file mapping for all file types\n const fileMapping = createFileMapping(\n filePaths,\n placeholderPaths,\n transformPaths,\n settings.files?.transformFormats || {},\n locales,\n settings.defaultLocale\n );\n\n // construct object\n const uploadData = allFiles.map((file) => {\n const sourceFile: FileToUpload = {\n content: file.content,\n fileName: file.fileName,\n fileFormat: file.fileFormat,\n transformFormat: file.transformFormat,\n dataFormat: file.dataFormat,\n locale: file.locale,\n fileId: file.fileId,\n versionId: file.versionId,\n };\n\n const translations: FileToUpload[] = [];\n const compositeInfo = compositeJsonFiles.get(file.fileName);\n\n for (const locale of locales) {\n if (compositeInfo) {\n // Composite JSON: extract translations from the same source file\n const extracted = extractJson(\n compositeInfo.content,\n compositeInfo.filePath,\n additionalOptions,\n locale,\n settings.defaultLocale\n );\n if (extracted) {\n translations.push({\n content: extracted,\n fileName: file.fileName,\n fileFormat: file.transformFormat ?? file.fileFormat,\n dataFormat: file.dataFormat,\n locale,\n fileId: file.fileId,\n versionId: file.versionId,\n });\n }\n } else {\n // Non-composite: look for separate translation files\n const translatedFileName = fileMapping[locale]?.[file.fileName];\n if (translatedFileName && existsSync(translatedFileName)) {\n const translatedContent = readFileSync(translatedFileName, 'utf8');\n translations.push({\n content: translatedContent,\n fileName: translatedFileName,\n fileFormat: file.transformFormat ?? file.fileFormat,\n dataFormat: file.dataFormat,\n locale,\n fileId: file.fileId,\n versionId: file.versionId,\n });\n }\n }\n }\n return {\n source: sourceFile,\n translations,\n };\n });\n\n try {\n // Send all files in a single API call\n const { branchData } = await runUploadFilesWorkflow({\n files: uploadData,\n options: settings,\n });\n\n // Publish files to CDN if publish config exists\n const publishMap = buildPublishMap(filePaths, settings);\n await runPublishWorkflow(\n allFiles,\n publishMap,\n branchData.currentBranch.id,\n settings\n );\n } catch (error) {\n logErrorAndExit(`Error uploading files: ${error}`);\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { logger } from "../../../console/logger.js";
|
|
2
|
+
import { devApiKeyError, noApiKeyError, noDefaultLocaleError, noLocalesError, noProjectIdError } from "../../../console/index.js";
|
|
3
|
+
//#region src/cli/commands/utils/validation.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
* Validate locales
|
|
6
|
+
* @param settings - The settings to validate
|
|
7
|
+
* @returns True if has locales and default locale
|
|
8
|
+
*/
|
|
9
|
+
function hasValidLocales(settings) {
|
|
10
|
+
if (!settings.locales) {
|
|
11
|
+
logger.error(noLocalesError);
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (!settings.defaultLocale) {
|
|
15
|
+
logger.error(noDefaultLocaleError);
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
* Validate credentials
|
|
22
|
+
* @param settings - The settings to validate
|
|
23
|
+
* @returns True if has API key, project ID, and does not have a development API key
|
|
24
|
+
*/
|
|
25
|
+
function hasValidCredentials(settings) {
|
|
26
|
+
if (!settings.apiKey) {
|
|
27
|
+
logger.error(noApiKeyError);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (settings.apiKey.startsWith("gtx-dev-")) {
|
|
31
|
+
logger.error(devApiKeyError);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (!settings.projectId) {
|
|
35
|
+
logger.error(noProjectIdError);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
38
39
|
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { hasValidCredentials, hasValidLocales };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","names":[],"sources":["../../../../src/cli/commands/utils/validation.ts"],"sourcesContent":["import {\n noDefaultLocaleError,\n noLocalesError,\n noApiKeyError,\n devApiKeyError,\n noProjectIdError,\n} from '../../../console/index.js';\nimport { logger } from '../../../console/logger.js';\nimport { Settings } from '../../../types/index.js';\n\n/**\n * Validate locales\n * @param settings - The settings to validate\n * @returns True if has locales and default locale\n */\nexport function hasValidLocales(settings: Settings): boolean {\n if (!settings.locales) {\n logger.error(noLocalesError);\n return false;\n }\n if (!settings.defaultLocale) {\n logger.error(noDefaultLocaleError);\n return false;\n }\n return true;\n}\n\n/**\n * Validate credentials\n * @param settings - The settings to validate\n * @returns True if has API key, project ID, and does not have a development API key\n */\nexport function hasValidCredentials(settings: Settings): boolean {\n if (!settings.apiKey) {\n logger.error(noApiKeyError);\n return false;\n }\n if (settings.apiKey.startsWith('gtx-dev-')) {\n logger.error(devApiKeyError);\n return false;\n }\n if (!settings.projectId) {\n logger.error(noProjectIdError);\n return false;\n }\n return true;\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,gBAAgB,UAA6B;AAC3D,KAAI,CAAC,SAAS,SAAS;AACrB,SAAO,MAAM,eAAe;AAC5B,SAAO;;AAET,KAAI,CAAC,SAAS,eAAe;AAC3B,SAAO,MAAM,qBAAqB;AAClC,SAAO;;AAET,QAAO;;;;;;;AAQT,SAAgB,oBAAoB,UAA6B;AAC/D,KAAI,CAAC,SAAS,QAAQ;AACpB,SAAO,MAAM,cAAc;AAC3B,SAAO;;AAET,KAAI,SAAS,OAAO,WAAW,WAAW,EAAE;AAC1C,SAAO,MAAM,eAAe;AAC5B,SAAO;;AAET,KAAI,CAAC,SAAS,WAAW;AACvB,SAAO,MAAM,iBAAiB;AAC9B,SAAO;;AAET,QAAO"}
|
package/dist/cli/flags.js
CHANGED
|
@@ -1,72 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { DEFAULT_GIT_REMOTE_NAME } from "../utils/constants.js";
|
|
2
|
+
import findFilepath from "../fs/findFilepath.js";
|
|
3
|
+
//#region src/cli/flags.ts
|
|
3
4
|
const DEFAULT_TIMEOUT = 900;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.option('--api-key <key>', 'API key for General Translation cloud service')
|
|
8
|
-
.option('--project-id <id>', 'General Translation project ID');
|
|
9
|
-
return command;
|
|
5
|
+
function attachSharedFlags(command) {
|
|
6
|
+
command.option("-c, --config <path>", "Filepath to config file, by default gt.config.json", findFilepath(["gt.config.json"])).option("--api-key <key>", "API key for General Translation cloud service").option("--project-id <id>", "General Translation project ID");
|
|
7
|
+
return command;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (isNaN(parsedValue)) {
|
|
20
|
-
throw new Error('Invalid timeout: not a number.');
|
|
21
|
-
}
|
|
22
|
-
if (parsedValue < 0) {
|
|
23
|
-
throw new Error('Invalid timeout: must be a positive number.');
|
|
24
|
-
}
|
|
25
|
-
return parsedValue;
|
|
26
|
-
}, DEFAULT_TIMEOUT)
|
|
27
|
-
.option('--save-local', 'Detect and save local edits before enqueuing translations', false)
|
|
28
|
-
.option('--publish', 'Publish translations to the CDN', false)
|
|
29
|
-
.option('--experimental-localize-static-urls', 'Triggering this will run a script after the cli tool that localizes all urls in content files. Currently only supported for md and mdx files.', false)
|
|
30
|
-
.option('--experimental-hide-default-locale', 'When localizing static locales, hide the default locale from the path', false)
|
|
31
|
-
.option('--experimental-flatten-json-files', 'Triggering this will flatten the json files into a single file. This is useful for projects that have a lot of json files.', false)
|
|
32
|
-
.option('--experimental-localize-static-imports', 'Triggering this will run a script after the cli tool that localizes all static imports in content files. Currently only supported for md and mdx files.', false)
|
|
33
|
-
.option('--experimental-localize-relative-assets', 'Triggering this will rewrite relative image asset URLs in translated md/mdx files to valid paths.', false)
|
|
34
|
-
.option('--force', 'Force a retranslation, invalidating all existing cached translations if they exist.', false)
|
|
35
|
-
.option('--force-download', 'Force download and overwrite local files, bypassing gt-lock.json checks.', false)
|
|
36
|
-
.option('--experimental-clear-locale-dirs', 'Clear locale directories before downloading new translations', false)
|
|
37
|
-
.option('--branch <branch>', 'Specify a custom branch to use for translations')
|
|
38
|
-
.option('--disable-branch-detection', 'Disable additional branch detection and optimizations and use the manually specified branch', false)
|
|
39
|
-
.option('--enable-branching', 'Enable branching for the project')
|
|
40
|
-
.option('--remote-name <name>', 'Specify a custom remote name to use for branch detection', DEFAULT_GIT_REMOTE_NAME)
|
|
41
|
-
.option('--tag [value]', 'Tag this translation run (auto-resolves from git if no value provided)')
|
|
42
|
-
.option('-m, --message <message>', 'Message to attach to the translation tag');
|
|
43
|
-
return command;
|
|
9
|
+
function attachTranslateFlags(command) {
|
|
10
|
+
attachSharedFlags(command).option("--version-id <id>", "General Translation version ID").option("--default-language, --default-locale <locale>", "Default locale (e.g., en)").option("--new, --locales <locales...>", "Space-separated list of locales (e.g., en fr es)").option("--dry-run", "Dry run, do not send updates to the General Translation API", false).option("--timeout <seconds>", "Translation wait timeout in seconds", (value) => {
|
|
11
|
+
const parsedValue = parseInt(value, 10);
|
|
12
|
+
if (isNaN(parsedValue)) throw new Error("Invalid timeout: not a number.");
|
|
13
|
+
if (parsedValue < 0) throw new Error("Invalid timeout: must be a positive number.");
|
|
14
|
+
return parsedValue;
|
|
15
|
+
}, DEFAULT_TIMEOUT).option("--save-local", "Detect and save local edits before enqueuing translations", false).option("--publish", "Publish translations to the CDN", false).option("--experimental-localize-static-urls", "Triggering this will run a script after the cli tool that localizes all urls in content files. Currently only supported for md and mdx files.", false).option("--experimental-hide-default-locale", "When localizing static locales, hide the default locale from the path", false).option("--experimental-flatten-json-files", "Triggering this will flatten the json files into a single file. This is useful for projects that have a lot of json files.", false).option("--experimental-localize-static-imports", "Triggering this will run a script after the cli tool that localizes all static imports in content files. Currently only supported for md and mdx files.", false).option("--experimental-localize-relative-assets", "Triggering this will rewrite relative image asset URLs in translated md/mdx files to valid paths.", false).option("--force", "Force a retranslation, invalidating all existing cached translations if they exist.", false).option("--force-download", "Force download and overwrite local files, bypassing gt-lock.json checks.", false).option("--experimental-clear-locale-dirs", "Clear locale directories before downloading new translations", false).option("--branch <branch>", "Specify a custom branch to use for translations").option("--disable-branch-detection", "Disable additional branch detection and optimizations and use the manually specified branch", false).option("--enable-branching", "Enable branching for the project").option("--remote-name <name>", "Specify a custom remote name to use for branch detection", DEFAULT_GIT_REMOTE_NAME).option("--tag [value]", "Tag this translation run (auto-resolves from git if no value provided)").option("-m, --message <message>", "Message to attach to the translation tag");
|
|
16
|
+
return command;
|
|
44
17
|
}
|
|
45
18
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
* Attaches flags necessary for parsing inline content
|
|
20
|
+
* @param command - The command to attach the flags to
|
|
21
|
+
* @returns The command with the inline content parsing flags attached
|
|
22
|
+
*/
|
|
50
23
|
function attachInlineContentParsingFlags(command) {
|
|
51
|
-
|
|
52
|
-
.option('--tsconfig, --jsconfig <path>', 'Path to custom jsconfig or tsconfig file', findFilepath(['./tsconfig.json', './jsconfig.json']))
|
|
53
|
-
.option('--dictionary <path>', 'Path to dictionary file')
|
|
54
|
-
.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}'")
|
|
55
|
-
.option('--inline', 'Include inline content in translations (e.g., inline jsx translations, inline string translations, etc.)', true);
|
|
24
|
+
return command.option("--tsconfig, --jsconfig <path>", "Path to custom jsconfig or tsconfig file", findFilepath(["./tsconfig.json", "./jsconfig.json"])).option("--dictionary <path>", "Path to dictionary file").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("--inline", "Include inline content in translations (e.g., inline jsx translations, inline string translations, etc.)", true);
|
|
56
25
|
}
|
|
57
26
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
27
|
+
* Attaches flags necessary for validating a project
|
|
28
|
+
* @param command
|
|
29
|
+
* @returns The command with the validate flags attached
|
|
30
|
+
*/
|
|
31
|
+
function attachValidateFlags(command) {
|
|
32
|
+
return attachInlineContentParsingFlags(command.option("-c, --config <path>", "Filepath to config file, by default gt.config.json", findFilepath(["gt.config.json"])));
|
|
64
33
|
}
|
|
65
34
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
35
|
+
* Attaches flags necessary for translating a project
|
|
36
|
+
* @param command
|
|
37
|
+
* @returns The command with the translate flags attached
|
|
38
|
+
*/
|
|
39
|
+
function attachInlineTranslateFlags(command) {
|
|
40
|
+
return attachInlineContentParsingFlags(command.option("--ignore-errors", "Ignore errors encountered while scanning for inline content", false));
|
|
72
41
|
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { attachInlineTranslateFlags, attachSharedFlags, attachTranslateFlags, attachValidateFlags };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.js","names":[],"sources":["../../src/cli/flags.ts"],"sourcesContent":["import { Command } from 'commander';\nimport findFilepath from '../fs/findFilepath.js';\nimport { DEFAULT_GIT_REMOTE_NAME } from '../utils/constants.js';\n\nconst DEFAULT_TIMEOUT = 900;\n\nexport function attachSharedFlags(command: Command) {\n command\n .option(\n '-c, --config <path>',\n 'Filepath to config file, by default gt.config.json',\n findFilepath(['gt.config.json'])\n )\n .option('--api-key <key>', 'API key for General Translation cloud service')\n .option('--project-id <id>', 'General Translation project ID');\n return command;\n}\n\nexport function attachTranslateFlags(command: Command) {\n attachSharedFlags(command)\n .option('--version-id <id>', 'General Translation version ID')\n .option(\n '--default-language, --default-locale <locale>',\n 'Default locale (e.g., en)'\n )\n .option(\n '--new, --locales <locales...>',\n 'Space-separated list of locales (e.g., en fr es)'\n )\n .option(\n '--dry-run',\n 'Dry run, do not send updates to the General Translation API',\n false\n )\n .option(\n '--timeout <seconds>',\n 'Translation wait timeout in seconds',\n (value) => {\n const parsedValue = parseInt(value, 10);\n if (isNaN(parsedValue)) {\n throw new Error('Invalid timeout: not a number.');\n }\n if (parsedValue < 0) {\n throw new Error('Invalid timeout: must be a positive number.');\n }\n return parsedValue;\n },\n DEFAULT_TIMEOUT\n )\n .option(\n '--save-local',\n 'Detect and save local edits before enqueuing translations',\n false\n )\n .option('--publish', 'Publish translations to the CDN', false)\n .option(\n '--experimental-localize-static-urls',\n 'Triggering this will run a script after the cli tool that localizes all urls in content files. Currently only supported for md and mdx files.',\n false\n )\n .option(\n '--experimental-hide-default-locale',\n 'When localizing static locales, hide the default locale from the path',\n false\n )\n .option(\n '--experimental-flatten-json-files',\n 'Triggering this will flatten the json files into a single file. This is useful for projects that have a lot of json files.',\n false\n )\n .option(\n '--experimental-localize-static-imports',\n 'Triggering this will run a script after the cli tool that localizes all static imports in content files. Currently only supported for md and mdx files.',\n false\n )\n .option(\n '--experimental-localize-relative-assets',\n 'Triggering this will rewrite relative image asset URLs in translated md/mdx files to valid paths.',\n false\n )\n .option(\n '--force',\n 'Force a retranslation, invalidating all existing cached translations if they exist.',\n false\n )\n .option(\n '--force-download',\n 'Force download and overwrite local files, bypassing gt-lock.json checks.',\n false\n )\n .option(\n '--experimental-clear-locale-dirs',\n 'Clear locale directories before downloading new translations',\n false\n )\n .option(\n '--branch <branch>',\n 'Specify a custom branch to use for translations'\n )\n .option(\n '--disable-branch-detection',\n 'Disable additional branch detection and optimizations and use the manually specified branch',\n false\n )\n .option('--enable-branching', 'Enable branching for the project')\n .option(\n '--remote-name <name>',\n 'Specify a custom remote name to use for branch detection',\n DEFAULT_GIT_REMOTE_NAME\n )\n .option(\n '--tag [value]',\n 'Tag this translation run (auto-resolves from git if no value provided)'\n )\n .option(\n '-m, --message <message>',\n 'Message to attach to the translation tag'\n );\n return command;\n}\n\n/**\n * Attaches flags necessary for parsing inline content\n * @param command - The command to attach the flags to\n * @returns The command with the inline content parsing flags attached\n */\nfunction attachInlineContentParsingFlags(command: Command) {\n return command\n .option(\n '--tsconfig, --jsconfig <path>',\n 'Path to custom jsconfig or tsconfig file',\n findFilepath(['./tsconfig.json', './jsconfig.json'])\n )\n .option('--dictionary <path>', 'Path to dictionary file')\n .option(\n '--src <paths...>',\n \"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}'\"\n )\n .option(\n '--inline',\n 'Include inline content in translations (e.g., inline jsx translations, inline string translations, etc.)',\n true\n );\n}\n\n/**\n * Attaches flags necessary for validating a project\n * @param command\n * @returns The command with the validate flags attached\n */\nexport function attachValidateFlags(command: Command) {\n return attachInlineContentParsingFlags(\n command.option(\n '-c, --config <path>',\n 'Filepath to config file, by default gt.config.json',\n findFilepath(['gt.config.json'])\n )\n );\n}\n\n/**\n * Attaches flags necessary for translating a project\n * @param command\n * @returns The command with the translate flags attached\n */\nexport function attachInlineTranslateFlags(command: Command) {\n return attachInlineContentParsingFlags(\n command.option(\n '--ignore-errors',\n 'Ignore errors encountered while scanning for inline content',\n false\n )\n );\n}\n"],"mappings":";;;AAIA,MAAM,kBAAkB;AAExB,SAAgB,kBAAkB,SAAkB;AAClD,SACG,OACC,uBACA,sDACA,aAAa,CAAC,iBAAiB,CAAC,CACjC,CACA,OAAO,mBAAmB,gDAAgD,CAC1E,OAAO,qBAAqB,iCAAiC;AAChE,QAAO;;AAGT,SAAgB,qBAAqB,SAAkB;AACrD,mBAAkB,QAAQ,CACvB,OAAO,qBAAqB,iCAAiC,CAC7D,OACC,iDACA,4BACD,CACA,OACC,iCACA,mDACD,CACA,OACC,aACA,+DACA,MACD,CACA,OACC,uBACA,wCACC,UAAU;EACT,MAAM,cAAc,SAAS,OAAO,GAAG;AACvC,MAAI,MAAM,YAAY,CACpB,OAAM,IAAI,MAAM,iCAAiC;AAEnD,MAAI,cAAc,EAChB,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO;IAET,gBACD,CACA,OACC,gBACA,6DACA,MACD,CACA,OAAO,aAAa,mCAAmC,MAAM,CAC7D,OACC,uCACA,iJACA,MACD,CACA,OACC,sCACA,yEACA,MACD,CACA,OACC,qCACA,8HACA,MACD,CACA,OACC,0CACA,2JACA,MACD,CACA,OACC,2CACA,qGACA,MACD,CACA,OACC,WACA,uFACA,MACD,CACA,OACC,oBACA,4EACA,MACD,CACA,OACC,oCACA,gEACA,MACD,CACA,OACC,qBACA,kDACD,CACA,OACC,8BACA,+FACA,MACD,CACA,OAAO,sBAAsB,mCAAmC,CAChE,OACC,wBACA,4DACA,wBACD,CACA,OACC,iBACA,yEACD,CACA,OACC,2BACA,2CACD;AACH,QAAO;;;;;;;AAQT,SAAS,gCAAgC,SAAkB;AACzD,QAAO,QACJ,OACC,iCACA,4CACA,aAAa,CAAC,mBAAmB,kBAAkB,CAAC,CACrD,CACA,OAAO,uBAAuB,0BAA0B,CACxD,OACC,oBACA,0MACD,CACA,OACC,YACA,4GACA,KACD;;;;;;;AAQL,SAAgB,oBAAoB,SAAkB;AACpD,QAAO,gCACL,QAAQ,OACN,uBACA,sDACA,aAAa,CAAC,iBAAiB,CAAC,CACjC,CACF;;;;;;;AAQH,SAAgB,2BAA2B,SAAkB;AAC3D,QAAO,gCACL,QAAQ,OACN,mBACA,+DACA,MACD,CACF"}
|
package/dist/cli/inline.js
CHANGED
|
@@ -1,140 +1,115 @@
|
|
|
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
|
|
1
|
+
import { logger } from "../console/logger.js";
|
|
2
|
+
import { displayHeader, exitSync } from "../console/logging.js";
|
|
3
|
+
import loadJSON from "../fs/loadJSON.js";
|
|
4
|
+
import { noFilesError } from "../console/index.js";
|
|
5
|
+
import "../types/libraries.js";
|
|
6
|
+
import { resolveLocaleFiles } from "../fs/config/parseFilesConfig.js";
|
|
7
|
+
import { generateSettings } from "../config/generateSettings.js";
|
|
8
|
+
import { validateProject } from "../translation/validate.js";
|
|
9
|
+
import { attachInlineTranslateFlags, attachTranslateFlags, attachValidateFlags } from "./flags.js";
|
|
10
|
+
import { aggregateInlineTranslations } from "../translation/stage.js";
|
|
11
|
+
import { BaseCLI } from "./base.js";
|
|
12
|
+
import { saveJSON } from "../fs/saveJSON.js";
|
|
13
|
+
import { intro } from "@clack/prompts";
|
|
14
|
+
import chalk from "chalk";
|
|
15
|
+
//#region src/cli/inline.ts
|
|
15
16
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
...newData,
|
|
102
|
-
...existingTranslations,
|
|
103
|
-
};
|
|
104
|
-
// Filter out keys that don't exist in newData
|
|
105
|
-
const filteredTranslations = Object.fromEntries(Object.entries(mergedTranslations).filter(([key]) => newData[key]));
|
|
106
|
-
await saveJSON(translationsFile.gt, filteredTranslations);
|
|
107
|
-
}
|
|
108
|
-
logger.step('Merged translations successfully!');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async handleValidate(initOptions, files) {
|
|
112
|
-
const settings = await generateSettings(initOptions, undefined, {
|
|
113
|
-
requireConfig: true,
|
|
114
|
-
});
|
|
115
|
-
// First run the base class's handleTranslate method
|
|
116
|
-
const options = { ...initOptions, ...settings };
|
|
117
|
-
// Fallback to gt-react
|
|
118
|
-
const pkg = fallbackToGtReact(this.library);
|
|
119
|
-
if (files && files.length > 0) {
|
|
120
|
-
// Validate specific files using createInlineUpdates
|
|
121
|
-
await validateProject(options, pkg, files);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
// Validate whole project as before
|
|
125
|
-
await validateProject(options, pkg);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
17
|
+
* Stand in for a CLI tool that does any sort of inline content translations
|
|
18
|
+
*/
|
|
19
|
+
var InlineCLI = class extends BaseCLI {
|
|
20
|
+
constructor(command, library, additionalModules) {
|
|
21
|
+
super(command, library, additionalModules);
|
|
22
|
+
}
|
|
23
|
+
init() {
|
|
24
|
+
this.setupStageCommand();
|
|
25
|
+
this.setupTranslateCommand();
|
|
26
|
+
this.setupGenerateSourceCommand();
|
|
27
|
+
this.setupValidateCommand();
|
|
28
|
+
this.setupDownloadCommand();
|
|
29
|
+
this.setupEnqueueCommand();
|
|
30
|
+
}
|
|
31
|
+
setupStageCommand() {
|
|
32
|
+
attachInlineTranslateFlags(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 (options) => {
|
|
33
|
+
displayHeader("Staging project for translation with approval required...");
|
|
34
|
+
await this.handleStage(options);
|
|
35
|
+
logger.endCommand("Done!");
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
setupTranslateCommand() {
|
|
39
|
+
attachInlineTranslateFlags(attachTranslateFlags(this.program.command("translate").description("Scans the project for a dictionary and inline translations and sends the updates to the General Translation API for translation."))).action(async (options) => {
|
|
40
|
+
displayHeader("Translating project...");
|
|
41
|
+
await this.handleTranslate(options);
|
|
42
|
+
logger.endCommand("Done!");
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
setupValidateCommand() {
|
|
46
|
+
attachValidateFlags(this.program.command("validate [files...]").description("Scans the project for a dictionary and/or inline content and validates the project for errors.")).action(async (files, options) => {
|
|
47
|
+
intro(chalk.cyan("Validating project..."));
|
|
48
|
+
await this.handleValidate(options, files);
|
|
49
|
+
logger.endCommand("Done!");
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
setupGenerateSourceCommand() {
|
|
53
|
+
attachInlineTranslateFlags(attachTranslateFlags(this.program.command("generate").description("Generate a translation file for the source locale. This command should be used if you are handling your own translations."))).action(async (initOptions) => {
|
|
54
|
+
displayHeader("Generating source templates...");
|
|
55
|
+
await this.handleGenerateSourceCommand(initOptions);
|
|
56
|
+
logger.endCommand("Done!");
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async handleGenerateSourceCommand(initOptions) {
|
|
60
|
+
const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
|
|
61
|
+
const updates = await aggregateInlineTranslations(initOptions, settings, fallbackToGtReact(this.library));
|
|
62
|
+
const newData = {};
|
|
63
|
+
for (const update of updates) {
|
|
64
|
+
const { source, metadata } = update;
|
|
65
|
+
const { hash, id } = metadata;
|
|
66
|
+
if (id) newData[id] = source;
|
|
67
|
+
else if (hash) newData[hash] = source;
|
|
68
|
+
}
|
|
69
|
+
if (settings.files && settings.files.placeholderPaths.gt) {
|
|
70
|
+
const translationFiles = resolveLocaleFiles(settings.files.placeholderPaths, settings.defaultLocale);
|
|
71
|
+
if (!translationFiles.gt) {
|
|
72
|
+
logger.error(noFilesError);
|
|
73
|
+
exitSync(1);
|
|
74
|
+
}
|
|
75
|
+
await saveJSON(translationFiles.gt, newData);
|
|
76
|
+
logger.step("Source file saved successfully!");
|
|
77
|
+
for (const locale of settings.locales) {
|
|
78
|
+
const translationsFile = resolveLocaleFiles(settings.files.placeholderPaths, locale);
|
|
79
|
+
if (!translationsFile.gt) continue;
|
|
80
|
+
const existingTranslations = loadJSON(translationsFile.gt);
|
|
81
|
+
const mergedTranslations = {
|
|
82
|
+
...newData,
|
|
83
|
+
...existingTranslations
|
|
84
|
+
};
|
|
85
|
+
const filteredTranslations = Object.fromEntries(Object.entries(mergedTranslations).filter(([key]) => newData[key]));
|
|
86
|
+
await saveJSON(translationsFile.gt, filteredTranslations);
|
|
87
|
+
}
|
|
88
|
+
logger.step("Merged translations successfully!");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async handleValidate(initOptions, files) {
|
|
92
|
+
const settings = await generateSettings(initOptions, void 0, { requireConfig: true });
|
|
93
|
+
const options = {
|
|
94
|
+
...initOptions,
|
|
95
|
+
...settings
|
|
96
|
+
};
|
|
97
|
+
const pkg = fallbackToGtReact(this.library);
|
|
98
|
+
if (files && files.length > 0) await validateProject(options, pkg, files);
|
|
99
|
+
else await validateProject(options, pkg);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
129
102
|
function fallbackToGtReact(library) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
? library
|
|
139
|
-
: Libraries.GT_REACT;
|
|
103
|
+
return [
|
|
104
|
+
"gt-next",
|
|
105
|
+
"gt-node",
|
|
106
|
+
"gt-react-native",
|
|
107
|
+
"gt-tanstack-start",
|
|
108
|
+
"gt-flask",
|
|
109
|
+
"gt-fastapi"
|
|
110
|
+
].includes(library) ? library : "gt-react";
|
|
140
111
|
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { InlineCLI };
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=inline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline.js","names":[],"sources":["../../src/cli/inline.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { BaseCLI } from './base.js';\nimport { SupportedLibraries, TranslateFlags, Options } from '../types/index.js';\nimport {\n attachInlineTranslateFlags,\n attachTranslateFlags,\n attachValidateFlags,\n} from './flags.js';\nimport { displayHeader, exitSync } from '../console/logging.js';\nimport { logger } from '../console/logger.js';\nimport { intro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { resolveLocaleFiles } from '../fs/config/parseFilesConfig.js';\nimport { noFilesError } from '../console/index.js';\nimport { saveJSON } from '../fs/saveJSON.js';\nimport loadJSON from '../fs/loadJSON.js';\nimport { generateSettings } from '../config/generateSettings.js';\nimport { aggregateInlineTranslations } from '../translation/stage.js';\nimport { validateProject } from '../translation/validate.js';\nimport { Libraries, InlineLibrary } from '../types/libraries.js';\n\n/**\n * Stand in for a CLI tool that does any sort of inline content translations\n */\nexport class InlineCLI extends BaseCLI {\n constructor(\n command: Command,\n library: InlineLibrary,\n additionalModules?: SupportedLibraries[]\n ) {\n super(command, library, additionalModules);\n }\n public init() {\n this.setupStageCommand();\n this.setupTranslateCommand();\n this.setupGenerateSourceCommand();\n this.setupValidateCommand();\n this.setupDownloadCommand();\n this.setupEnqueueCommand();\n }\n\n protected setupStageCommand(): void {\n attachInlineTranslateFlags(\n attachTranslateFlags(\n this.program\n .command('stage')\n .description(\n 'Submits the project to the General Translation API for translation. Translations created using this command will require human approval.'\n )\n )\n ).action(async (options: TranslateFlags) => {\n displayHeader(\n 'Staging project for translation with approval required...'\n );\n await this.handleStage(options);\n logger.endCommand('Done!');\n });\n }\n\n protected setupTranslateCommand(): void {\n attachInlineTranslateFlags(\n attachTranslateFlags(\n this.program\n .command('translate')\n .description(\n 'Scans the project for a dictionary and inline translations and sends the updates to the General Translation API for translation.'\n )\n )\n ).action(async (options: TranslateFlags) => {\n displayHeader('Translating project...');\n await this.handleTranslate(options);\n logger.endCommand('Done!');\n });\n }\n\n protected setupValidateCommand(): void {\n attachValidateFlags(\n this.program\n .command('validate [files...]')\n .description(\n 'Scans the project for a dictionary and/or inline content and validates the project for errors.'\n )\n ).action(async (files: string[], options: Options) => {\n // intro here since we don't want to show the ascii title\n intro(chalk.cyan('Validating project...'));\n await this.handleValidate(options, files);\n logger.endCommand('Done!');\n });\n }\n\n protected setupGenerateSourceCommand(): void {\n attachInlineTranslateFlags(\n attachTranslateFlags(\n this.program\n .command('generate')\n .description(\n 'Generate a translation file for the source locale. This command should be used if you are handling your own translations.'\n )\n )\n ).action(async (initOptions: TranslateFlags) => {\n displayHeader('Generating source templates...');\n await this.handleGenerateSourceCommand(initOptions);\n logger.endCommand('Done!');\n });\n }\n\n protected async handleGenerateSourceCommand(\n initOptions: TranslateFlags\n ): Promise<void> {\n const settings = await generateSettings(initOptions, undefined, {\n requireConfig: true,\n });\n\n const updates = await aggregateInlineTranslations(\n initOptions,\n settings,\n fallbackToGtReact(this.library)\n );\n\n // Convert updates to the proper data format\n const newData: Record<string, unknown> = {};\n for (const update of updates) {\n const { source, metadata } = update;\n const { hash, id } = metadata;\n if (id) {\n newData[id] = source;\n } else if (hash) {\n newData[hash] = source;\n }\n }\n\n // Save source file if files.json is provided\n if (settings.files && settings.files.placeholderPaths.gt) {\n const translationFiles = resolveLocaleFiles(\n settings.files.placeholderPaths,\n settings.defaultLocale\n );\n if (!translationFiles.gt) {\n logger.error(noFilesError);\n exitSync(1);\n }\n await saveJSON(translationFiles.gt, newData);\n logger.step('Source file saved successfully!');\n // Also save translations (after merging with existing translations)\n for (const locale of settings.locales) {\n const translationsFile = resolveLocaleFiles(\n settings.files.placeholderPaths,\n locale\n );\n\n if (!translationsFile.gt) {\n continue;\n }\n const existingTranslations = loadJSON(translationsFile.gt);\n const mergedTranslations = {\n ...newData,\n ...existingTranslations,\n };\n // Filter out keys that don't exist in newData\n const filteredTranslations = Object.fromEntries(\n Object.entries(mergedTranslations).filter(([key]) => newData[key])\n );\n await saveJSON(translationsFile.gt, filteredTranslations);\n }\n logger.step('Merged translations successfully!');\n }\n }\n\n protected async handleValidate(\n initOptions: Options,\n files?: string[]\n ): Promise<void> {\n const settings = await generateSettings(initOptions, undefined, {\n requireConfig: true,\n });\n\n // First run the base class's handleTranslate method\n const options = { ...initOptions, ...settings };\n\n // Fallback to gt-react\n const pkg = fallbackToGtReact(this.library);\n\n if (files && files.length > 0) {\n // Validate specific files using createInlineUpdates\n await validateProject(options, pkg, files);\n } else {\n // Validate whole project as before\n await validateProject(options, pkg);\n }\n }\n}\n\nfunction fallbackToGtReact(library: SupportedLibraries): InlineLibrary {\n return [\n Libraries.GT_NEXT,\n Libraries.GT_NODE,\n Libraries.GT_REACT_NATIVE,\n Libraries.GT_TANSTACK_START,\n Libraries.GT_FLASK,\n Libraries.GT_FASTAPI,\n ].includes(library as Libraries)\n ? (library as\n | typeof Libraries.GT_NEXT\n | typeof Libraries.GT_NODE\n | typeof Libraries.GT_REACT_NATIVE\n | typeof Libraries.GT_TANSTACK_START\n | typeof Libraries.GT_FLASK\n | typeof Libraries.GT_FASTAPI)\n : Libraries.GT_REACT;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,IAAa,YAAb,cAA+B,QAAQ;CACrC,YACE,SACA,SACA,mBACA;AACA,QAAM,SAAS,SAAS,kBAAkB;;CAE5C,OAAc;AACZ,OAAK,mBAAmB;AACxB,OAAK,uBAAuB;AAC5B,OAAK,4BAA4B;AACjC,OAAK,sBAAsB;AAC3B,OAAK,sBAAsB;AAC3B,OAAK,qBAAqB;;CAG5B,oBAAoC;AAClC,6BACE,qBACE,KAAK,QACF,QAAQ,QAAQ,CAChB,YACC,2IACD,CACJ,CACF,CAAC,OAAO,OAAO,YAA4B;AAC1C,iBACE,4DACD;AACD,SAAM,KAAK,YAAY,QAAQ;AAC/B,UAAO,WAAW,QAAQ;IAC1B;;CAGJ,wBAAwC;AACtC,6BACE,qBACE,KAAK,QACF,QAAQ,YAAY,CACpB,YACC,mIACD,CACJ,CACF,CAAC,OAAO,OAAO,YAA4B;AAC1C,iBAAc,yBAAyB;AACvC,SAAM,KAAK,gBAAgB,QAAQ;AACnC,UAAO,WAAW,QAAQ;IAC1B;;CAGJ,uBAAuC;AACrC,sBACE,KAAK,QACF,QAAQ,sBAAsB,CAC9B,YACC,iGACD,CACJ,CAAC,OAAO,OAAO,OAAiB,YAAqB;AAEpD,SAAM,MAAM,KAAK,wBAAwB,CAAC;AAC1C,SAAM,KAAK,eAAe,SAAS,MAAM;AACzC,UAAO,WAAW,QAAQ;IAC1B;;CAGJ,6BAA6C;AAC3C,6BACE,qBACE,KAAK,QACF,QAAQ,WAAW,CACnB,YACC,4HACD,CACJ,CACF,CAAC,OAAO,OAAO,gBAAgC;AAC9C,iBAAc,iCAAiC;AAC/C,SAAM,KAAK,4BAA4B,YAAY;AACnD,UAAO,WAAW,QAAQ;IAC1B;;CAGJ,MAAgB,4BACd,aACe;EACf,MAAM,WAAW,MAAM,iBAAiB,aAAa,KAAA,GAAW,EAC9D,eAAe,MAChB,CAAC;EAEF,MAAM,UAAU,MAAM,4BACpB,aACA,UACA,kBAAkB,KAAK,QAAQ,CAChC;EAGD,MAAM,UAAmC,EAAE;AAC3C,OAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,EAAE,QAAQ,aAAa;GAC7B,MAAM,EAAE,MAAM,OAAO;AACrB,OAAI,GACF,SAAQ,MAAM;YACL,KACT,SAAQ,QAAQ;;AAKpB,MAAI,SAAS,SAAS,SAAS,MAAM,iBAAiB,IAAI;GACxD,MAAM,mBAAmB,mBACvB,SAAS,MAAM,kBACf,SAAS,cACV;AACD,OAAI,CAAC,iBAAiB,IAAI;AACxB,WAAO,MAAM,aAAa;AAC1B,aAAS,EAAE;;AAEb,SAAM,SAAS,iBAAiB,IAAI,QAAQ;AAC5C,UAAO,KAAK,kCAAkC;AAE9C,QAAK,MAAM,UAAU,SAAS,SAAS;IACrC,MAAM,mBAAmB,mBACvB,SAAS,MAAM,kBACf,OACD;AAED,QAAI,CAAC,iBAAiB,GACpB;IAEF,MAAM,uBAAuB,SAAS,iBAAiB,GAAG;IAC1D,MAAM,qBAAqB;KACzB,GAAG;KACH,GAAG;KACJ;IAED,MAAM,uBAAuB,OAAO,YAClC,OAAO,QAAQ,mBAAmB,CAAC,QAAQ,CAAC,SAAS,QAAQ,KAAK,CACnE;AACD,UAAM,SAAS,iBAAiB,IAAI,qBAAqB;;AAE3D,UAAO,KAAK,oCAAoC;;;CAIpD,MAAgB,eACd,aACA,OACe;EACf,MAAM,WAAW,MAAM,iBAAiB,aAAa,KAAA,GAAW,EAC9D,eAAe,MAChB,CAAC;EAGF,MAAM,UAAU;GAAE,GAAG;GAAa,GAAG;GAAU;EAG/C,MAAM,MAAM,kBAAkB,KAAK,QAAQ;AAE3C,MAAI,SAAS,MAAM,SAAS,EAE1B,OAAM,gBAAgB,SAAS,KAAK,MAAM;MAG1C,OAAM,gBAAgB,SAAS,IAAI;;;AAKzC,SAAS,kBAAkB,SAA4C;AACrE,QAAO;;;;;;;EAON,CAAC,SAAS,QAAqB,GAC3B,UAAA"}
|
package/dist/cli/next.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { wrapContentNext } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
import "../types/libraries.js";
|
|
2
|
+
import { wrapContentNext } from "../next/parse/wrapContent.js";
|
|
3
|
+
import { ReactCLI } from "./react.js";
|
|
4
|
+
//#region src/cli/next.ts
|
|
5
|
+
const pkg = "gt-next";
|
|
6
|
+
var NextCLI = class extends ReactCLI {
|
|
7
|
+
constructor(command, library, additionalModules) {
|
|
8
|
+
super(command, library, additionalModules);
|
|
9
|
+
}
|
|
10
|
+
wrapContent(options, framework, errors, warnings) {
|
|
11
|
+
return wrapContentNext(options, pkg, errors, warnings);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { NextCLI };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.js","names":[],"sources":["../../src/cli/next.ts"],"sourcesContent":["import {\n WrapOptions,\n SupportedFrameworks,\n SupportedLibraries,\n} from '../types/index.js';\nimport { ReactCLI } from './react.js';\nimport { wrapContentNext } from '../next/parse/wrapContent.js';\nimport { Command } from 'commander';\nimport { Libraries } from '../types/libraries.js';\n\nconst pkg = Libraries.GT_NEXT;\n\nexport class NextCLI extends ReactCLI {\n constructor(\n command: Command,\n library: typeof Libraries.GT_NEXT,\n additionalModules?: SupportedLibraries[]\n ) {\n super(command, library, additionalModules);\n }\n\n protected wrapContent(\n options: WrapOptions,\n framework: SupportedFrameworks,\n errors: string[],\n warnings: string[]\n ): Promise<{ filesUpdated: string[] }> {\n return wrapContentNext(options, pkg, errors, warnings);\n }\n}\n"],"mappings":";;;;AAUA,MAAM,MAAA;AAEN,IAAa,UAAb,cAA6B,SAAS;CACpC,YACE,SACA,SACA,mBACA;AACA,QAAM,SAAS,SAAS,kBAAkB;;CAG5C,YACE,SACA,WACA,QACA,UACqC;AACrC,SAAO,gBAAgB,SAAS,KAAK,QAAQ,SAAS"}
|
package/dist/cli/node.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { checkMonorepoVersionConsistency } from
|
|
1
|
+
import { NODE_LIBRARIES } from "../types/libraries.js";
|
|
2
|
+
import { InlineCLI } from "./inline.js";
|
|
3
|
+
import { checkMonorepoVersionConsistency } from "../utils/monorepoVersionCheck.js";
|
|
4
|
+
//#region src/cli/node.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
* CLI tool for managing translations with gt-node
|
|
7
|
+
*/
|
|
8
|
+
var NodeCLI = class extends InlineCLI {
|
|
9
|
+
constructor(command, library, additionalModules) {
|
|
10
|
+
super(command, library, additionalModules);
|
|
11
|
+
this.program.hook("preAction", () => {
|
|
12
|
+
if (this.program.opts().skipVersionCheck) return;
|
|
13
|
+
checkMonorepoVersionConsistency(NODE_LIBRARIES);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { NodeCLI };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../../src/cli/node.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { SupportedLibraries } from '../types/index.js';\nimport { InlineCLI } from './inline.js';\nimport { Libraries, NODE_LIBRARIES } from '../types/libraries.js';\nimport { checkMonorepoVersionConsistency } from '../utils/monorepoVersionCheck.js';\n\n/**\n * CLI tool for managing translations with gt-node\n */\nexport class NodeCLI extends InlineCLI {\n constructor(\n command: Command,\n library: typeof Libraries.GT_NODE,\n additionalModules?: SupportedLibraries[]\n ) {\n super(command, library, additionalModules);\n\n this.program.hook('preAction', () => {\n if (this.program.opts().skipVersionCheck) return;\n checkMonorepoVersionConsistency(NODE_LIBRARIES);\n });\n }\n}\n"],"mappings":";;;;;;;AASA,IAAa,UAAb,cAA6B,UAAU;CACrC,YACE,SACA,SACA,mBACA;AACA,QAAM,SAAS,SAAS,kBAAkB;AAE1C,OAAK,QAAQ,KAAK,mBAAmB;AACnC,OAAI,KAAK,QAAQ,MAAM,CAAC,iBAAkB;AAC1C,mCAAgC,eAAe;IAC/C"}
|