gt 0.10.0 → 2.7.0
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 +1275 -0
- package/LICENSE.md +105 -0
- package/README.md +26 -198
- package/dist/api/collectUserEditDiffs.d.ts +9 -0
- package/dist/api/collectUserEditDiffs.js +159 -0
- package/dist/api/downloadFileBatch.d.ts +23 -0
- package/dist/api/downloadFileBatch.js +190 -0
- package/dist/api/saveLocalEdits.d.ts +6 -0
- package/dist/api/saveLocalEdits.js +38 -0
- package/dist/bin/bin-entry.d.ts +1 -0
- package/dist/bin/bin-entry.js +9 -0
- package/dist/bin/bin-main.d.ts +2 -0
- package/dist/bin/bin-main.js +67 -0
- package/dist/cli/base.d.ts +59 -0
- package/dist/cli/base.js +529 -0
- package/dist/cli/commands/download.d.ts +8 -0
- package/dist/cli/commands/download.js +51 -0
- package/dist/cli/commands/enqueue.d.ts +9 -0
- package/dist/cli/commands/enqueue.js +27 -0
- package/dist/cli/commands/setupProject.d.ts +7 -0
- package/dist/cli/commands/setupProject.js +37 -0
- package/dist/cli/commands/stage.d.ts +9 -0
- package/dist/cli/commands/stage.js +59 -0
- package/dist/cli/commands/translate.d.ts +7 -0
- package/dist/cli/commands/translate.js +70 -0
- package/dist/cli/commands/upload.d.ts +13 -0
- package/dist/cli/commands/upload.js +142 -0
- package/dist/cli/commands/utils/validation.d.ts +13 -0
- package/dist/cli/commands/utils/validation.js +38 -0
- package/dist/cli/flags.d.ts +15 -0
- package/dist/cli/flags.js +70 -0
- package/dist/cli/inline.d.ts +17 -0
- package/dist/cli/inline.js +135 -0
- package/dist/cli/next.d.ts +10 -0
- package/dist/cli/next.js +12 -0
- package/dist/cli/node.d.ts +10 -0
- package/dist/cli/node.js +9 -0
- package/dist/cli/react.d.ts +12 -0
- package/dist/cli/react.js +72 -0
- package/dist/config/generateSettings.d.ts +9 -0
- package/dist/config/generateSettings.js +214 -0
- package/dist/config/optionPresets.d.ts +3 -0
- package/dist/config/optionPresets.js +65 -0
- package/dist/config/resolveConfig.d.ts +4 -0
- package/dist/config/resolveConfig.js +33 -0
- package/dist/config/utils.d.ts +2 -0
- package/dist/config/utils.js +4 -0
- package/dist/config/validateSettings.d.ts +3 -0
- package/dist/config/validateSettings.js +32 -0
- package/dist/console/colors.d.ts +6 -0
- package/dist/console/colors.js +19 -0
- package/dist/console/displayTranslateSummary.d.ts +1 -0
- package/dist/console/displayTranslateSummary.js +42 -0
- package/dist/console/formatting.d.ts +1 -0
- package/dist/console/formatting.js +7 -0
- package/dist/console/index.d.ts +34 -0
- package/dist/console/index.js +46 -0
- package/dist/console/logger.d.ts +35 -0
- package/dist/console/logger.js +250 -0
- package/dist/console/logging.d.ts +52 -0
- package/dist/console/logging.js +175 -0
- package/dist/formats/files/aggregateFiles.d.ts +4 -0
- package/dist/formats/files/aggregateFiles.js +156 -0
- package/dist/formats/files/collectFiles.d.ts +6 -0
- package/dist/formats/files/collectFiles.js +49 -0
- package/dist/formats/files/convertToFileTranslationData.d.ts +15 -0
- package/dist/formats/files/convertToFileTranslationData.js +21 -0
- package/dist/formats/files/fileMapping.d.ts +11 -0
- package/dist/formats/files/fileMapping.js +115 -0
- package/dist/formats/files/preprocess/mdx.d.ts +6 -0
- package/dist/formats/files/preprocess/mdx.js +14 -0
- package/dist/formats/files/preprocess/mintlify.d.ts +5 -0
- package/dist/formats/files/preprocess/mintlify.js +15 -0
- package/dist/formats/files/preprocessContent.d.ts +8 -0
- package/dist/formats/files/preprocessContent.js +23 -0
- package/dist/formats/files/save.d.ts +5 -0
- package/dist/formats/files/save.js +17 -0
- package/dist/formats/files/supportedFiles.d.ts +11 -0
- package/dist/formats/files/supportedFiles.js +20 -0
- package/dist/formats/json/extractJson.d.ts +15 -0
- package/dist/formats/json/extractJson.js +101 -0
- package/dist/formats/json/flattenJson.d.ts +14 -0
- package/dist/formats/json/flattenJson.js +64 -0
- package/dist/formats/json/mergeJson.d.ts +13 -0
- package/dist/formats/json/mergeJson.js +367 -0
- package/dist/formats/json/parseJson.d.ts +2 -0
- package/dist/formats/json/parseJson.js +109 -0
- package/dist/formats/json/utils.d.ts +47 -0
- package/dist/formats/json/utils.js +150 -0
- package/dist/formats/utils.d.ts +2 -0
- package/dist/formats/utils.js +24 -0
- package/dist/formats/yaml/mergeYaml.d.ts +5 -0
- package/dist/formats/yaml/mergeYaml.js +61 -0
- package/dist/formats/yaml/parseYaml.d.ts +5 -0
- package/dist/formats/yaml/parseYaml.js +24 -0
- package/dist/formats/yaml/utils.d.ts +2 -0
- package/dist/formats/yaml/utils.js +23 -0
- package/dist/fs/clearLocaleDirs.d.ts +8 -0
- package/dist/fs/clearLocaleDirs.js +126 -0
- package/dist/fs/config/downloadedVersions.d.ts +21 -0
- package/dist/fs/config/downloadedVersions.js +50 -0
- package/dist/fs/config/loadConfig.d.ts +1 -0
- package/dist/fs/config/loadConfig.js +9 -0
- package/dist/fs/config/parseFilesConfig.d.ts +27 -0
- package/dist/fs/config/parseFilesConfig.js +150 -0
- package/dist/fs/config/setupConfig.d.ts +17 -0
- package/dist/fs/config/setupConfig.js +50 -0
- package/dist/fs/config/updateConfig.d.ts +21 -0
- package/dist/fs/config/updateConfig.js +57 -0
- package/dist/fs/config/updateVersions.d.ts +11 -0
- package/dist/fs/config/updateVersions.js +30 -0
- package/dist/fs/copyFile.d.ts +7 -0
- package/dist/fs/copyFile.js +39 -0
- package/dist/fs/createLoadTranslationsFile.d.ts +1 -0
- package/dist/fs/createLoadTranslationsFile.js +49 -0
- package/dist/fs/determineFramework.d.ts +5 -0
- package/dist/fs/determineFramework.js +53 -0
- package/dist/fs/findFilepath.d.ts +36 -0
- package/dist/fs/findFilepath.js +90 -0
- package/dist/fs/index.d.ts +1 -0
- package/dist/fs/index.js +1 -0
- package/dist/fs/loadJSON.d.ts +6 -0
- package/dist/fs/loadJSON.js +17 -0
- package/dist/fs/matchFiles.d.ts +1 -0
- package/dist/fs/matchFiles.js +8 -0
- package/dist/fs/saveJSON.d.ts +1 -0
- package/dist/fs/saveJSON.js +7 -0
- package/dist/fs/utils.d.ts +1 -0
- package/dist/fs/utils.js +16 -0
- package/dist/functions.d.ts +7 -0
- package/dist/functions.js +6 -0
- package/dist/generated/version.d.ts +1 -0
- package/dist/generated/version.js +2 -0
- package/dist/git/branches.d.ts +7 -0
- package/dist/git/branches.js +88 -0
- package/dist/hooks/postProcess.d.ts +4 -0
- package/dist/hooks/postProcess.js +110 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +27 -0
- package/dist/locadex/setupFlow.d.ts +2 -0
- package/dist/locadex/setupFlow.js +9 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +10 -0
- package/dist/next/config/parseNextConfig.d.ts +10 -0
- package/dist/next/config/parseNextConfig.js +53 -0
- package/dist/next/jsx/utils.d.ts +7 -0
- package/dist/next/jsx/utils.js +42 -0
- package/dist/next/parse/handleInitGT.d.ts +7 -0
- package/dist/next/parse/handleInitGT.js +157 -0
- package/dist/next/parse/wrapContent.d.ts +12 -0
- package/dist/next/parse/wrapContent.js +164 -0
- package/dist/react/config/createESBuildConfig.d.ts +2 -0
- package/dist/react/config/createESBuildConfig.js +119 -0
- package/dist/react/jsx/evaluateJsx.d.ts +24 -0
- package/dist/react/jsx/evaluateJsx.js +123 -0
- package/dist/react/jsx/utils/buildImportMap.d.ts +9 -0
- package/dist/react/jsx/utils/buildImportMap.js +30 -0
- package/dist/react/jsx/utils/constants.d.ts +15 -0
- package/dist/react/jsx/utils/constants.js +49 -0
- package/dist/react/jsx/utils/getCalleeNameFromExpression.d.ts +9 -0
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js +32 -0
- package/dist/react/jsx/utils/getPathsAndAliases.d.ts +21 -0
- package/dist/react/jsx/utils/getPathsAndAliases.js +91 -0
- package/dist/react/jsx/utils/isNumberLiteral.d.ts +7 -0
- package/dist/react/jsx/utils/isNumberLiteral.js +13 -0
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.d.ts +9 -0
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +138 -0
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.d.ts +6 -0
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +197 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.d.ts +13 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +42 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.d.ts +5 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +69 -0
- package/dist/react/jsx/utils/jsxParsing/parseJsx.d.ts +33 -0
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js +918 -0
- package/dist/react/jsx/utils/jsxParsing/parseTProps.d.ts +8 -0
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js +65 -0
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.d.ts +2 -0
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +61 -0
- package/dist/react/jsx/utils/jsxParsing/types.d.ts +48 -0
- package/dist/react/jsx/utils/jsxParsing/types.js +34 -0
- package/dist/react/jsx/utils/mapAttributeName.d.ts +11 -0
- package/dist/react/jsx/utils/mapAttributeName.js +12 -0
- package/dist/react/jsx/utils/parseAst.d.ts +31 -0
- package/dist/react/jsx/utils/parseAst.js +278 -0
- package/dist/react/jsx/utils/parseDeclareStatic.d.ts +15 -0
- package/dist/react/jsx/utils/parseDeclareStatic.js +540 -0
- package/dist/react/jsx/utils/parseString.d.ts +25 -0
- package/dist/react/jsx/utils/parseString.js +540 -0
- package/dist/react/jsx/utils/parseStringFunction.d.ts +30 -0
- package/dist/react/jsx/utils/parseStringFunction.js +348 -0
- package/dist/react/jsx/utils/resolveImportPath.d.ts +11 -0
- package/dist/react/jsx/utils/resolveImportPath.js +111 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.d.ts +29 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +86 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.d.ts +14 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +24 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.d.ts +19 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +31 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.d.ts +22 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.js +51 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.d.ts +18 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +39 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.d.ts +24 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +68 -0
- package/dist/react/jsx/utils/stringParsing/types.d.ts +41 -0
- package/dist/react/jsx/utils/stringParsing/types.js +1 -0
- package/dist/react/jsx/utils/types.d.ts +14 -0
- package/dist/react/jsx/utils/types.js +1 -0
- package/dist/react/jsx/utils/validateStringFunction.d.ts +7 -0
- package/dist/react/jsx/utils/validateStringFunction.js +31 -0
- package/dist/react/jsx/wrapJsx.d.ts +51 -0
- package/dist/react/jsx/wrapJsx.js +387 -0
- package/dist/react/parse/addVitePlugin/index.d.ts +22 -0
- package/dist/react/parse/addVitePlugin/index.js +41 -0
- package/dist/react/parse/addVitePlugin/installCompiler.d.ts +8 -0
- package/dist/react/parse/addVitePlugin/installCompiler.js +22 -0
- package/dist/react/parse/addVitePlugin/updateViteConfig.d.ts +19 -0
- package/dist/react/parse/addVitePlugin/updateViteConfig.js +120 -0
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.d.ts +9 -0
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +34 -0
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.d.ts +11 -0
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +48 -0
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.d.ts +15 -0
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +113 -0
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.d.ts +12 -0
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +32 -0
- package/dist/react/parse/createDictionaryUpdates.d.ts +3 -0
- package/dist/react/parse/createDictionaryUpdates.js +187 -0
- package/dist/react/parse/createInlineUpdates.d.ts +13 -0
- package/dist/react/parse/createInlineUpdates.js +161 -0
- package/dist/react/parse/wrapContent.d.ts +12 -0
- package/dist/react/parse/wrapContent.js +162 -0
- package/dist/react/utils/flattenDictionary.d.ts +20 -0
- package/dist/react/utils/flattenDictionary.js +75 -0
- package/dist/react/utils/getEntryAndMetadata.d.ts +5 -0
- package/dist/react/utils/getEntryAndMetadata.js +11 -0
- package/dist/react/utils/getVariableName.d.ts +25 -0
- package/dist/react/utils/getVariableName.js +37 -0
- package/dist/setup/agentInstructions.d.ts +24 -0
- package/dist/setup/agentInstructions.js +138 -0
- package/dist/setup/detectFramework.d.ts +31 -0
- package/dist/setup/detectFramework.js +106 -0
- package/dist/setup/frameworkUtils.d.ts +3 -0
- package/dist/setup/frameworkUtils.js +30 -0
- package/dist/setup/instructions/base.md +29 -0
- package/dist/setup/instructions/gt-next.md +107 -0
- package/dist/setup/instructions/gt-react.md +98 -0
- package/dist/setup/userInput.d.ts +4 -0
- package/dist/setup/userInput.js +32 -0
- package/dist/setup/wizard.d.ts +3 -0
- package/dist/setup/wizard.js +147 -0
- package/dist/state/recentDownloads.d.ts +12 -0
- package/dist/state/recentDownloads.js +18 -0
- package/dist/state/translateWarnings.d.ts +10 -0
- package/dist/state/translateWarnings.js +13 -0
- package/dist/translation/parse.d.ts +17 -0
- package/dist/translation/parse.js +77 -0
- package/dist/translation/stage.d.ts +3 -0
- package/dist/translation/stage.js +44 -0
- package/dist/translation/validate.d.ts +14 -0
- package/dist/translation/validate.js +100 -0
- package/dist/types/branch.d.ts +14 -0
- package/dist/types/branch.js +1 -0
- package/dist/types/data/json.d.ts +6 -0
- package/dist/types/data/json.js +1 -0
- package/dist/types/data.d.ts +37 -0
- package/dist/types/data.js +1 -0
- package/dist/types/files.d.ts +8 -0
- package/dist/types/files.js +1 -0
- package/dist/types/index.d.ts +243 -0
- package/dist/types/index.js +1 -0
- package/dist/types/libraries.d.ts +31 -0
- package/dist/types/libraries.js +72 -0
- package/dist/types/parsing.d.ts +3 -0
- package/dist/types/parsing.js +1 -0
- package/dist/utils/addExplicitAnchorIds.d.ts +24 -0
- package/dist/utils/addExplicitAnchorIds.js +416 -0
- package/dist/utils/constants.d.ts +5 -0
- package/dist/utils/constants.js +6 -0
- package/dist/utils/credentials.d.ts +12 -0
- package/dist/utils/credentials.js +120 -0
- package/dist/utils/flattenJsonFiles.d.ts +2 -0
- package/dist/utils/flattenJsonFiles.js +36 -0
- package/dist/utils/gitDiff.d.ts +8 -0
- package/dist/utils/gitDiff.js +34 -0
- package/dist/utils/gt.d.ts +2 -0
- package/dist/utils/gt.js +2 -0
- package/dist/utils/hash.d.ts +6 -0
- package/dist/utils/hash.js +11 -0
- package/dist/utils/headers.d.ts +1 -0
- package/dist/utils/headers.js +14 -0
- package/dist/utils/installPackage.d.ts +3 -0
- package/dist/utils/installPackage.js +77 -0
- package/dist/utils/localizeRelativeAssets.d.ts +8 -0
- package/dist/utils/localizeRelativeAssets.js +166 -0
- package/dist/utils/localizeStaticImports.d.ts +15 -0
- package/dist/utils/localizeStaticImports.js +397 -0
- package/dist/utils/localizeStaticUrls.d.ts +19 -0
- package/dist/utils/localizeStaticUrls.js +450 -0
- package/dist/utils/mintlifyTitleFallback.d.ts +6 -0
- package/dist/utils/mintlifyTitleFallback.js +80 -0
- package/dist/utils/packageInfo.d.ts +3 -0
- package/dist/utils/packageInfo.js +17 -0
- package/dist/utils/packageJson.d.ts +6 -0
- package/dist/utils/packageJson.js +68 -0
- package/dist/utils/packageManager.d.ts +28 -0
- package/dist/utils/packageManager.js +269 -0
- package/dist/utils/parse/needsCJS.d.ts +20 -0
- package/dist/utils/parse/needsCJS.js +72 -0
- package/dist/utils/persistPostprocessHashes.d.ts +12 -0
- package/dist/utils/persistPostprocessHashes.js +39 -0
- package/dist/utils/processAnchorIds.d.ts +6 -0
- package/dist/utils/processAnchorIds.js +56 -0
- package/dist/utils/processOpenApi.d.ts +8 -0
- package/dist/utils/processOpenApi.js +651 -0
- package/dist/utils/sanitizeFileContent.d.ts +6 -0
- package/dist/utils/sanitizeFileContent.js +29 -0
- package/dist/utils/sharedStaticAssets.d.ts +9 -0
- package/dist/utils/sharedStaticAssets.js +384 -0
- package/dist/utils/validateMdx.d.ts +10 -0
- package/dist/utils/validateMdx.js +25 -0
- package/dist/utils/wrapPlainUrls.d.ts +8 -0
- package/dist/utils/wrapPlainUrls.js +72 -0
- package/dist/workflows/download.d.ts +32 -0
- package/dist/workflows/download.js +131 -0
- package/dist/workflows/enqueue.d.ts +17 -0
- package/dist/workflows/enqueue.js +59 -0
- package/dist/workflows/setupProject.d.ts +13 -0
- package/dist/workflows/setupProject.js +48 -0
- package/dist/workflows/stage.d.ts +18 -0
- package/dist/workflows/stage.js +59 -0
- package/dist/workflows/steps/BranchStep.d.ts +13 -0
- package/dist/workflows/steps/BranchStep.js +161 -0
- package/dist/workflows/steps/DownloadStep.d.ts +19 -0
- package/dist/workflows/steps/DownloadStep.js +131 -0
- package/dist/workflows/steps/EnqueueStep.d.ts +15 -0
- package/dist/workflows/steps/EnqueueStep.js +33 -0
- package/dist/workflows/steps/PollJobsStep.d.ts +31 -0
- package/dist/workflows/steps/PollJobsStep.js +288 -0
- package/dist/workflows/steps/SetupStep.d.ts +16 -0
- package/dist/workflows/steps/SetupStep.js +72 -0
- package/dist/workflows/steps/UploadSourcesStep.d.ts +27 -0
- package/dist/workflows/steps/UploadSourcesStep.js +131 -0
- package/dist/workflows/steps/UploadTranslationsStep.d.ts +22 -0
- package/dist/workflows/steps/UploadTranslationsStep.js +71 -0
- package/dist/workflows/steps/UserEditDiffsStep.d.ts +11 -0
- package/dist/workflows/steps/UserEditDiffsStep.js +30 -0
- package/dist/workflows/steps/WorkflowStep.d.ts +4 -0
- package/dist/workflows/steps/WorkflowStep.js +2 -0
- package/dist/workflows/upload.d.ts +15 -0
- package/dist/workflows/upload.js +47 -0
- package/package.json +149 -112
- package/.dont-break +0 -6
- package/.jshintrc +0 -76
- package/.npmignore +0 -9
- package/.travis.yml +0 -21
- package/Gruntfile.js +0 -65
- package/History.md +0 -90
- package/MIT-License.txt +0 -21
- package/bin/gt.js +0 -58
- package/complexity.json +0 -17
- package/doc/RequireJsExample.md +0 -10
- package/examples/all.js +0 -72
- package/examples/altAsserrionSyntax/tests.js +0 -32
- package/examples/amd/bar.js +0 -4
- package/examples/amd/foo.js +0 -15
- package/examples/amd/fooTests.js +0 -8
- package/examples/arrays/test.js +0 -15
- package/examples/assert/test-assert-object.js +0 -15
- package/examples/assert/test-assert-require.js +0 -17
- package/examples/async/asyncAll.js +0 -37
- package/examples/async/asyncSetup.js +0 -29
- package/examples/async/asyncSetupOnce.js +0 -25
- package/examples/async/asyncTeardown.js +0 -27
- package/examples/async/stopStart.js +0 -22
- package/examples/async/test.js +0 -43
- package/examples/async/timeoutTests.js +0 -19
- package/examples/basic/code.js +0 -50
- package/examples/basic/code2.js +0 -9
- package/examples/basic/default.js +0 -26
- package/examples/basic/definedUndefined.js +0 -28
- package/examples/basic/empty.js +0 -24
- package/examples/basic/exceptionTests.js +0 -55
- package/examples/basic/fullMessage.js +0 -28
- package/examples/basic/functions.js +0 -18
- package/examples/basic/incomplete.js +0 -16
- package/examples/basic/null.js +0 -17
- package/examples/basic/optional.js +0 -45
- package/examples/basic/tests.js +0 -147
- package/examples/bdd/spec.js +0 -67
- package/examples/browser/code_coverage_report.json +0 -1
- package/examples/browser/index.html +0 -50
- package/examples/browser/packages.js +0 -12
- package/examples/browser/packagesDefault.js +0 -12
- package/examples/browser/qunit/qunit-1.10.0.css +0 -235
- package/examples/browser/qunit/qunit-1.10.0.js +0 -1977
- package/examples/browser/runTestsWithCoverage.bat +0 -19
- package/examples/browser/runner.js +0 -178
- package/examples/browser/src/Foo.js +0 -14
- package/examples/browser/srcInstrumented/Foo.js +0 -6
- package/examples/browser/test/FooTest.js +0 -31
- package/examples/browser/testDojo.js +0 -63
- package/examples/browser/testInstrumented/FooTest.js +0 -6
- package/examples/coffee/coffeeTestsCoffee/foo.coffee +0 -4
- package/examples/coffee/coffeeTestsCoffee/tests.coffee +0 -7
- package/examples/coffee/coffeeTestsJs/foo.js +0 -9
- package/examples/coffee/coffeeTestsJs/tests.coffee +0 -9
- package/examples/coffee/jsTestsCoffee/foo.coffee +0 -4
- package/examples/coffee/jsTestsCoffee/tests.js +0 -8
- package/examples/coverage.png +0 -0
- package/examples/crash/foo.js +0 -8
- package/examples/crashOnLoading/foo.js +0 -3
- package/examples/crashStackSize/foo.js +0 -8
- package/examples/crashStackSize/test.js +0 -7
- package/examples/doh/foo.js +0 -15
- package/examples/doh/fooTests.js +0 -28
- package/examples/dohDefine/foo.js +0 -14
- package/examples/dohDefine/fooTests.js +0 -24
- package/examples/dojo/src/Foo.js +0 -12
- package/examples/dojo/test/FooTest.js +0 -9
- package/examples/dojo/testDojo.js +0 -69
- package/examples/equiv/equiv.js +0 -22
- package/examples/example.png +0 -0
- package/examples/exec/foo.js +0 -5
- package/examples/exec/tests.js +0 -50
- package/examples/expect/test.js +0 -53
- package/examples/extend/extend-through-api.js +0 -40
- package/examples/extend/test.js +0 -18
- package/examples/faster/fibonacci.js +0 -18
- package/examples/faster/test.js +0 -89
- package/examples/fluent/foo.js +0 -38
- package/examples/funcAndArity/test.js +0 -15
- package/examples/gtAndQUnit/gtTests.js +0 -6
- package/examples/gtAndQUnit/qunitTests.js +0 -5
- package/examples/jsUnity/foo.js +0 -10
- package/examples/jsUnity/fooTests.js +0 -19
- package/examples/lodash/totalLength.js +0 -19
- package/examples/longStrings/test.js +0 -27
- package/examples/moduleSetupTeardown/test.js +0 -115
- package/examples/namedTest/foo.js +0 -9
- package/examples/overrideGt/test.js +0 -11
- package/examples/quickFail/test.js +0 -22
- package/examples/qunit/foo.js +0 -13
- package/examples/reporting/tests.coffee +0 -9
- package/examples/requirejs/lib/Foo.js +0 -11
- package/examples/requirejs/lib/Rectangle.js +0 -13
- package/examples/requirejs/runTests.js +0 -5
- package/examples/requirejs/test/RectangleTest.js +0 -22
- package/examples/silent/foo.js +0 -7
- package/examples/silent/fooTest.js +0 -18
- package/examples/skipTest/tests.js +0 -15
- package/examples/testsFromOtherTests/parentTests.js +0 -7
- package/examples/testsFromOtherTests/tests.js +0 -5
- package/examples/throws/test.js +0 -17
- package/examples/use-gt-as-module/fooTest.js +0 -8
- package/examples/use-gt-as-module/test-code.js +0 -7
- package/gt.js +0 -11
- package/lib/coverage.js +0 -234
- package/src/JUnitReporter.js +0 -30
- package/src/QUnitBrowserAdapter.js +0 -15
- package/src/Reporter.js +0 -127
- package/src/TestRunInfo.js +0 -25
- package/src/TestRunner.js +0 -223
- package/src/UnitTest/CollectionMethods.js +0 -97
- package/src/UnitTest/ModuleTests.js +0 -104
- package/src/UnitTest/Test.js +0 -85
- package/src/UnitTest/TestAsync.js +0 -78
- package/src/UnitTest/TestBaseInfo.js +0 -21
- package/src/UnitTest/TestCollection.js +0 -206
- package/src/UnitTest/TestInfo.js +0 -30
- package/src/UnitTest/TestReport.js +0 -27
- package/src/assertions/PrimaryAssertions.js +0 -163
- package/src/assertions/SecondaryAssertions.js +0 -262
- package/src/assertions/TertiaryAssertions.js +0 -99
- package/src/bddInterface.js +0 -39
- package/src/covered.js +0 -156
- package/src/dohAdapter.js +0 -79
- package/src/dohInterface.js +0 -20
- package/src/equiv.js +0 -11
- package/src/jsunityAdapter.js +0 -66
- package/src/jsunityInterface.js +0 -13
- package/src/options.js +0 -116
- package/src/shiv.js +0 -16
- package/src/sure.js +0 -226
- package/src/test/ConsoleHider.js +0 -26
- package/src/test/JUnitReporter.js +0 -12
- package/src/test/ModuleTests.js +0 -37
- package/src/test/Test.js +0 -18
- package/src/test/TestCollection.js +0 -21
- package/src/test/TestRunInfo.js +0 -15
- package/src/test/TestRunner.js +0 -9
- package/src/test/utils.js +0 -43
- package/src/utils/ConsoleHider.js +0 -27
- package/src/utils/WatchFiles.js +0 -13
- package/src/utils/discoverFiles.js +0 -18
- package/src/utils/joinArguments.js +0 -13
- package/src/utils/not.js +0 -14
- package/src/utils/pluckFunction.js +0 -15
- package/src/utils/test/joinArgumentsTest.js +0 -24
- package/src/utils/test/not.js +0 -70
- package/src/utils/test/pluckFunctionLoDashTest.js +0 -51
- package/src/utils/test/pluckFunctionTest.js +0 -41
- package/src/utils/test/pluckObjects.js +0 -20
- package/src/utils/utils.js +0 -146
- package/tests/all.js +0 -24
- package/tests/large/bddTest.js +0 -9
- package/tests/large/expectedCrash.js +0 -3
- package/tests/large/expectedCrashTest.js +0 -9
- package/tests/large/filterCLI.js +0 -10
- package/tests/large/filterCLITest.js +0 -18
- package/tests/large/loadingCrash.js +0 -1
- package/tests/large/loadingCrashTest.js +0 -9
- package/tests/large/skip.js +0 -11
- package/tests/large/skipTest.js +0 -9
- package/tests/large/twoFailing.js +0 -9
- package/tests/large/twoFailingTest.js +0 -9
- package/tests/mocha/.npmignore +0 -1
- package/tests/mocha/basic.js +0 -12
- package/tests/mocha/gt-as-module.js +0 -65
- package/tests/mocha/test-collection.js +0 -67
- package/tests/small/errorInAsync.js +0 -6
- package/tests/small/errorInAsyncTest.js +0 -14
- package/tests/small/oneFails.js +0 -7
- package/tests/small/oneFailsTest.js +0 -18
- package/tests/small/pluckObjects.js +0 -20
- package/tests/small/pluckTest.js +0 -51
- package/tests/small/setupException.js +0 -8
- package/tests/small/setupExceptionTest.js +0 -9
- package/tests/small/teardownException.js +0 -8
- package/tests/small/teardownExceptionTest.js +0 -9
package/dist/cli/next.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactCLI } from './react.js';
|
|
2
|
+
import { wrapContentNext } from '../next/parse/wrapContent.js';
|
|
3
|
+
import { Libraries } from '../types/libraries.js';
|
|
4
|
+
const pkg = Libraries.GT_NEXT;
|
|
5
|
+
export class NextCLI extends ReactCLI {
|
|
6
|
+
constructor(command, library, additionalModules) {
|
|
7
|
+
super(command, library, additionalModules);
|
|
8
|
+
}
|
|
9
|
+
wrapContent(options, framework, errors, warnings) {
|
|
10
|
+
return wrapContentNext(options, pkg, errors, warnings);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { SupportedLibraries } from '../types/index.js';
|
|
3
|
+
import { InlineCLI } from './inline.js';
|
|
4
|
+
import { Libraries } from '../types/libraries.js';
|
|
5
|
+
/**
|
|
6
|
+
* CLI tool for managing translations with gt-node
|
|
7
|
+
*/
|
|
8
|
+
export declare class NodeCLI extends InlineCLI {
|
|
9
|
+
constructor(command: Command, library: typeof Libraries.GT_NODE, additionalModules?: SupportedLibraries[]);
|
|
10
|
+
}
|
package/dist/cli/node.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Framework, SupportedFrameworks, WrapOptions, SupportedLibraries } from '../types/index.js';
|
|
3
|
+
import { InlineCLI } from './inline.js';
|
|
4
|
+
export declare class ReactCLI extends InlineCLI {
|
|
5
|
+
constructor(command: Command, library: Framework, additionalModules?: SupportedLibraries[]);
|
|
6
|
+
init(): void;
|
|
7
|
+
protected wrapContent(options: WrapOptions, framework: SupportedFrameworks, errors: string[], warnings: string[]): Promise<{
|
|
8
|
+
filesUpdated: string[];
|
|
9
|
+
}>;
|
|
10
|
+
protected setupSetupProjectCommand(): void;
|
|
11
|
+
protected handleScanCommand(options: WrapOptions): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { displayHeader, exitSync, promptConfirm } from '../console/logging.js';
|
|
2
|
+
import { logger } from '../console/logger.js';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { formatFiles } from '../hooks/postProcess.js';
|
|
5
|
+
import { wrapContentReact } from '../react/parse/wrapContent.js';
|
|
6
|
+
import { generateSettings } from '../config/generateSettings.js';
|
|
7
|
+
import { attachInlineTranslateFlags, attachTranslateFlags } from './flags.js';
|
|
8
|
+
import { InlineCLI } from './inline.js';
|
|
9
|
+
import { Libraries } from '../types/libraries.js';
|
|
10
|
+
const pkg = Libraries.GT_REACT;
|
|
11
|
+
export class ReactCLI extends InlineCLI {
|
|
12
|
+
constructor(command, library, additionalModules) {
|
|
13
|
+
super(command, library, additionalModules);
|
|
14
|
+
}
|
|
15
|
+
init() {
|
|
16
|
+
super.init();
|
|
17
|
+
this.setupSetupProjectCommand();
|
|
18
|
+
}
|
|
19
|
+
wrapContent(options, framework, errors, warnings) {
|
|
20
|
+
return wrapContentReact(options, pkg, framework, errors, warnings);
|
|
21
|
+
}
|
|
22
|
+
setupSetupProjectCommand() {
|
|
23
|
+
attachInlineTranslateFlags(attachTranslateFlags(this.program
|
|
24
|
+
.command('setup')
|
|
25
|
+
.description('Upload source files and setup the project for translation'))).action(async (options) => {
|
|
26
|
+
displayHeader('Uploading source files and setting up project...');
|
|
27
|
+
await this.handleSetupProject(options);
|
|
28
|
+
logger.endCommand('Done!');
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async handleScanCommand(options) {
|
|
32
|
+
// Ask user for confirmation using inquirer
|
|
33
|
+
const answer = await promptConfirm({
|
|
34
|
+
message: chalk.yellow('Warning: This operation will modify your source files! Make sure you have committed or stashed your current changes. Do you want to continue?'),
|
|
35
|
+
defaultValue: true,
|
|
36
|
+
});
|
|
37
|
+
if (!answer) {
|
|
38
|
+
logger.error('Operation cancelled.');
|
|
39
|
+
exitSync(0);
|
|
40
|
+
}
|
|
41
|
+
// ----- Create a starter gt.config.json file -----
|
|
42
|
+
await generateSettings(options);
|
|
43
|
+
// ----- //
|
|
44
|
+
const includeTId = await promptConfirm({
|
|
45
|
+
message: 'Do you want to include an unique id for each <T> tag?',
|
|
46
|
+
defaultValue: true,
|
|
47
|
+
});
|
|
48
|
+
options.disableIds = !includeTId;
|
|
49
|
+
const errors = [];
|
|
50
|
+
const warnings = [];
|
|
51
|
+
// Wrap all JSX elements in the src directory with a <T> tag, with unique ids
|
|
52
|
+
const { filesUpdated } = await this.wrapContent(options, 'react', errors, warnings);
|
|
53
|
+
if (errors.length > 0) {
|
|
54
|
+
logger.error(chalk.red('Failed to write files:\n') + errors.join('\n'));
|
|
55
|
+
}
|
|
56
|
+
// Format updated files if formatters are available
|
|
57
|
+
if (!options.disableFormatting)
|
|
58
|
+
await formatFiles(filesUpdated);
|
|
59
|
+
logger.success(`Success! Added <T> tags and updated ${chalk.bold.cyan(filesUpdated.length)} files:\n` +
|
|
60
|
+
filesUpdated.map((file) => `${chalk.green('-')} ${file}`).join('\n'));
|
|
61
|
+
if (filesUpdated.length > 0) {
|
|
62
|
+
logger.step(chalk.green('Please verify the changes before committing.'));
|
|
63
|
+
}
|
|
64
|
+
if (warnings.length > 0) {
|
|
65
|
+
logger.warn(chalk.yellow('Warnings encountered:') +
|
|
66
|
+
'\n' +
|
|
67
|
+
warnings
|
|
68
|
+
.map((warning) => `${chalk.yellow('-')} ${warning}`)
|
|
69
|
+
.join('\n'));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Settings } from '../types/index.js';
|
|
2
|
+
export declare const DEFAULT_SRC_PATTERNS: string[];
|
|
3
|
+
/**
|
|
4
|
+
* Generates settings from any
|
|
5
|
+
* @param flags - The CLI flags to generate settings from
|
|
6
|
+
* @param cwd - The current working directory
|
|
7
|
+
* @returns The generated settings
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateSettings(flags: Record<string, any>, cwd?: string): Promise<Settings>;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { displayProjectId, exitSync, logErrorAndExit, warnApiKeyInConfig, } from '../console/logging.js';
|
|
2
|
+
import { loadConfig } from '../fs/config/loadConfig.js';
|
|
3
|
+
import { defaultBaseUrl, libraryDefaultLocale, } from 'generaltranslation/internal';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { createOrUpdateConfig } from '../fs/config/setupConfig.js';
|
|
6
|
+
import { resolveFiles } from '../fs/config/parseFilesConfig.js';
|
|
7
|
+
import { validateSettings } from './validateSettings.js';
|
|
8
|
+
import { DEFAULT_GIT_REMOTE_NAME, GT_DASHBOARD_URL, } from '../utils/constants.js';
|
|
9
|
+
import { resolveProjectId } from '../fs/utils.js';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { resolveConfig } from './resolveConfig.js';
|
|
13
|
+
import { gt } from '../utils/gt.js';
|
|
14
|
+
import { generatePreset } from './optionPresets.js';
|
|
15
|
+
export const DEFAULT_SRC_PATTERNS = [
|
|
16
|
+
'src/**/*.{js,jsx,ts,tsx}',
|
|
17
|
+
'app/**/*.{js,jsx,ts,tsx}',
|
|
18
|
+
'pages/**/*.{js,jsx,ts,tsx}',
|
|
19
|
+
'components/**/*.{js,jsx,ts,tsx}',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Generates settings from any
|
|
23
|
+
* @param flags - The CLI flags to generate settings from
|
|
24
|
+
* @param cwd - The current working directory
|
|
25
|
+
* @returns The generated settings
|
|
26
|
+
*/
|
|
27
|
+
export async function generateSettings(flags, cwd = process.cwd()) {
|
|
28
|
+
// Load config file
|
|
29
|
+
let gtConfig = {};
|
|
30
|
+
if (flags.config && !flags.config.endsWith('.json')) {
|
|
31
|
+
flags.config = `${flags.config}.json`;
|
|
32
|
+
}
|
|
33
|
+
if (flags.config) {
|
|
34
|
+
gtConfig = loadConfig(flags.config);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const config = resolveConfig(cwd);
|
|
38
|
+
if (config) {
|
|
39
|
+
gtConfig = config.config;
|
|
40
|
+
flags.config = config.path;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
gtConfig = {};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Warn if apiKey is present in gt.config.json
|
|
47
|
+
if (gtConfig.apiKey) {
|
|
48
|
+
warnApiKeyInConfig(flags.config);
|
|
49
|
+
exitSync(1);
|
|
50
|
+
}
|
|
51
|
+
const projectIdEnv = resolveProjectId();
|
|
52
|
+
// Resolve mismatched projectIds
|
|
53
|
+
if (gtConfig.projectId &&
|
|
54
|
+
flags.projectId &&
|
|
55
|
+
gtConfig.projectId !== flags.projectId) {
|
|
56
|
+
logErrorAndExit(`Project ID mismatch between ${chalk.green(gtConfig.projectId)} and ${chalk.green(flags.projectId)}! Please use the same projectId in all configs.`);
|
|
57
|
+
}
|
|
58
|
+
else if (gtConfig.projectId &&
|
|
59
|
+
projectIdEnv &&
|
|
60
|
+
gtConfig.projectId !== projectIdEnv) {
|
|
61
|
+
logErrorAndExit(`Project ID mismatch between ${chalk.green(gtConfig.projectId)} and ${chalk.green(projectIdEnv)}! Please use the same projectId in all configs.`);
|
|
62
|
+
}
|
|
63
|
+
if (flags.options?.docsUrlPattern &&
|
|
64
|
+
!flags.options?.docsUrlPattern.includes('[locale]')) {
|
|
65
|
+
logErrorAndExit('Failed to localize static urls: URL pattern must include "[locale]" to denote the location of the locale');
|
|
66
|
+
}
|
|
67
|
+
if (flags.options?.docsImportPattern &&
|
|
68
|
+
!flags.options?.docsImportPattern.includes('[locale]')) {
|
|
69
|
+
logErrorAndExit('Failed to localize static imports: Import pattern must include "[locale]" to denote the location of the locale');
|
|
70
|
+
}
|
|
71
|
+
if (flags.options?.copyFiles) {
|
|
72
|
+
for (const file of flags.options.copyFiles) {
|
|
73
|
+
if (!file.includes('[locale]')) {
|
|
74
|
+
logErrorAndExit('Failed to copy files: File path must include "[locale]" to denote the location of the locale');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// merge options
|
|
79
|
+
const mergedOptions = { ...gtConfig, ...flags };
|
|
80
|
+
// Add defaultLocale if not provided
|
|
81
|
+
mergedOptions.defaultLocale =
|
|
82
|
+
mergedOptions.defaultLocale || libraryDefaultLocale;
|
|
83
|
+
// merge locales
|
|
84
|
+
mergedOptions.locales = Array.from(new Set([...(gtConfig.locales || []), ...(flags.locales || [])]));
|
|
85
|
+
// Separate defaultLocale from locales
|
|
86
|
+
mergedOptions.locales = mergedOptions.locales.filter((locale) => locale !== mergedOptions.defaultLocale);
|
|
87
|
+
// Add apiKey if not provided
|
|
88
|
+
mergedOptions.apiKey = mergedOptions.apiKey || process.env.GT_API_KEY;
|
|
89
|
+
// Add projectId if not provided
|
|
90
|
+
mergedOptions.projectId = mergedOptions.projectId || resolveProjectId();
|
|
91
|
+
// Add baseUrl if not provided
|
|
92
|
+
mergedOptions.baseUrl = mergedOptions.baseUrl || defaultBaseUrl;
|
|
93
|
+
// Add dashboardUrl if not provided
|
|
94
|
+
mergedOptions.dashboardUrl = mergedOptions.dashboardUrl || GT_DASHBOARD_URL;
|
|
95
|
+
// Add locales if not provided
|
|
96
|
+
mergedOptions.locales = mergedOptions.locales || [];
|
|
97
|
+
// Add default config file name if not provided
|
|
98
|
+
mergedOptions.config =
|
|
99
|
+
mergedOptions.config || path.join(cwd, 'gt.config.json');
|
|
100
|
+
// Display projectId if present
|
|
101
|
+
if (mergedOptions.projectId)
|
|
102
|
+
displayProjectId(mergedOptions.projectId);
|
|
103
|
+
// Add stageTranslations if not provided
|
|
104
|
+
// For human review, always stage the project
|
|
105
|
+
mergedOptions.stageTranslations = mergedOptions.stageTranslations ?? false;
|
|
106
|
+
// Add publish if not provided
|
|
107
|
+
mergedOptions.publish = (gtConfig.publish || flags.publish) ?? false;
|
|
108
|
+
// Populate src if not provided
|
|
109
|
+
mergedOptions.src = mergedOptions.src || DEFAULT_SRC_PATTERNS;
|
|
110
|
+
// Resolve all glob patterns in the files object
|
|
111
|
+
const compositePatterns = [
|
|
112
|
+
...Object.entries(mergedOptions.options?.jsonSchema || {}),
|
|
113
|
+
]
|
|
114
|
+
.filter(([, schema]) => schema.composite)
|
|
115
|
+
.map(([key]) => key);
|
|
116
|
+
mergedOptions.files = mergedOptions.files
|
|
117
|
+
? resolveFiles(mergedOptions.files, mergedOptions.defaultLocale, mergedOptions.locales, cwd, compositePatterns)
|
|
118
|
+
: { resolvedPaths: {}, placeholderPaths: {}, transformPaths: {} };
|
|
119
|
+
mergedOptions.options = {
|
|
120
|
+
...(mergedOptions.options || {}),
|
|
121
|
+
mintlify: {
|
|
122
|
+
...(mergedOptions.options?.mintlify || {}),
|
|
123
|
+
inferTitleFromFilename: gtConfig.options?.mintlify?.inferTitleFromFilename ||
|
|
124
|
+
mergedOptions.options?.mintlify?.inferTitleFromFilename,
|
|
125
|
+
},
|
|
126
|
+
experimentalLocalizeStaticImports: gtConfig.options?.experimentalLocalizeStaticImports ||
|
|
127
|
+
flags.experimentalLocalizeStaticImports,
|
|
128
|
+
experimentalLocalizeStaticUrls: gtConfig.options?.experimentalLocalizeStaticUrls ||
|
|
129
|
+
flags.experimentalLocalizeStaticUrls,
|
|
130
|
+
experimentalLocalizeRelativeAssets: gtConfig.options?.experimentalLocalizeRelativeAssets ||
|
|
131
|
+
flags.experimentalLocalizeRelativeAssets,
|
|
132
|
+
experimentalHideDefaultLocale: gtConfig.options?.experimentalHideDefaultLocale ||
|
|
133
|
+
flags.experimentalHideDefaultLocale,
|
|
134
|
+
experimentalFlattenJsonFiles: gtConfig.options?.experimentalFlattenJsonFiles ||
|
|
135
|
+
flags.experimentalFlattenJsonFiles,
|
|
136
|
+
experimentalClearLocaleDirs: gtConfig.options?.experimentalClearLocaleDirs ||
|
|
137
|
+
flags.experimentalClearLocaleDirs,
|
|
138
|
+
clearLocaleDirsExclude: gtConfig.options?.clearLocaleDirsExclude || flags.clearLocaleDirsExclude,
|
|
139
|
+
};
|
|
140
|
+
// Add additional options if provided
|
|
141
|
+
if (mergedOptions.options) {
|
|
142
|
+
if (mergedOptions.options.jsonSchema) {
|
|
143
|
+
for (const fileGlob of Object.keys(mergedOptions.options.jsonSchema)) {
|
|
144
|
+
const jsonSchema = mergedOptions.options.jsonSchema[fileGlob];
|
|
145
|
+
if (jsonSchema.preset) {
|
|
146
|
+
mergedOptions.options.jsonSchema[fileGlob] = {
|
|
147
|
+
...generatePreset(jsonSchema.preset, 'json'),
|
|
148
|
+
...jsonSchema,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (mergedOptions.options.yamlSchema) {
|
|
154
|
+
for (const fileGlob of Object.keys(mergedOptions.options.yamlSchema)) {
|
|
155
|
+
const yamlSchema = mergedOptions.options.yamlSchema[fileGlob];
|
|
156
|
+
if (yamlSchema.preset) {
|
|
157
|
+
mergedOptions.options.yamlSchema[fileGlob] = {
|
|
158
|
+
...generatePreset(yamlSchema.preset, 'yaml'),
|
|
159
|
+
...yamlSchema,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Add parsing options if not provided
|
|
166
|
+
mergedOptions.parsingOptions = mergedOptions.parsingOptions || {};
|
|
167
|
+
mergedOptions.parsingOptions.conditionNames = mergedOptions.parsingOptions
|
|
168
|
+
.conditionNames || [
|
|
169
|
+
'development',
|
|
170
|
+
'browser',
|
|
171
|
+
'module',
|
|
172
|
+
'import',
|
|
173
|
+
'require',
|
|
174
|
+
'default',
|
|
175
|
+
];
|
|
176
|
+
// Add branch options if not provided
|
|
177
|
+
const branchOptions = mergedOptions.branchOptions || {};
|
|
178
|
+
// If --branch is set, enable branching
|
|
179
|
+
branchOptions.enabled =
|
|
180
|
+
flags.enableBranching ??
|
|
181
|
+
gtConfig.branchOptions?.enabled ??
|
|
182
|
+
(flags.branch ? true : false);
|
|
183
|
+
branchOptions.currentBranch =
|
|
184
|
+
flags.branch ?? gtConfig.branchOptions?.currentBranch ?? undefined;
|
|
185
|
+
branchOptions.autoDetectBranches = flags.disableBranchDetection
|
|
186
|
+
? false
|
|
187
|
+
: (gtConfig.branchOptions?.autoDetectBranches ?? true);
|
|
188
|
+
branchOptions.remoteName =
|
|
189
|
+
flags.remoteName ??
|
|
190
|
+
gtConfig.branchOptions?.remoteName ??
|
|
191
|
+
DEFAULT_GIT_REMOTE_NAME;
|
|
192
|
+
mergedOptions.branchOptions = branchOptions;
|
|
193
|
+
// if there's no existing config file, creates one
|
|
194
|
+
// does not include the API key to avoid exposing it
|
|
195
|
+
if (!fs.existsSync(mergedOptions.config)) {
|
|
196
|
+
await createOrUpdateConfig(mergedOptions.config, {
|
|
197
|
+
projectId: mergedOptions.projectId,
|
|
198
|
+
defaultLocale: mergedOptions.defaultLocale,
|
|
199
|
+
locales: mergedOptions.locales?.length > 0 ? mergedOptions.locales : undefined,
|
|
200
|
+
framework: mergedOptions.framework,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
mergedOptions.configDirectory = path.join(cwd, '.gt');
|
|
204
|
+
validateSettings(mergedOptions);
|
|
205
|
+
// Set up GT instance
|
|
206
|
+
gt.setConfig({
|
|
207
|
+
projectId: mergedOptions.projectId,
|
|
208
|
+
apiKey: mergedOptions.apiKey,
|
|
209
|
+
baseUrl: mergedOptions.baseUrl,
|
|
210
|
+
sourceLocale: mergedOptions.defaultLocale,
|
|
211
|
+
customMapping: mergedOptions.customMapping,
|
|
212
|
+
});
|
|
213
|
+
return mergedOptions;
|
|
214
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export function generatePreset(preset, type) {
|
|
2
|
+
if (type === 'json') {
|
|
3
|
+
switch (preset) {
|
|
4
|
+
case 'mintlify':
|
|
5
|
+
// https://mintlify.com/docs/navigation
|
|
6
|
+
return {
|
|
7
|
+
composite: {
|
|
8
|
+
'$.navigation.languages': {
|
|
9
|
+
type: 'array',
|
|
10
|
+
key: '$.language',
|
|
11
|
+
experimentalSort: 'localesAlphabetical',
|
|
12
|
+
include: [
|
|
13
|
+
'$..group',
|
|
14
|
+
'$..tab',
|
|
15
|
+
'$..item',
|
|
16
|
+
'$..anchor',
|
|
17
|
+
'$..dropdown',
|
|
18
|
+
],
|
|
19
|
+
transform: {
|
|
20
|
+
'$..pages[*]': {
|
|
21
|
+
match: '^{locale}/(.*)$',
|
|
22
|
+
replace: '{locale}/$1',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
'$.redirects': {
|
|
27
|
+
type: 'array',
|
|
28
|
+
key: '$.language',
|
|
29
|
+
include: [],
|
|
30
|
+
transform: {
|
|
31
|
+
'$.source': {
|
|
32
|
+
match: '^/{locale}/(.*)$',
|
|
33
|
+
replace: '/{locale}/$1',
|
|
34
|
+
},
|
|
35
|
+
'$.destination': {
|
|
36
|
+
match: '^/{locale}/(.*)$',
|
|
37
|
+
replace: '/{locale}/$1',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
case 'openapi':
|
|
44
|
+
return {
|
|
45
|
+
include: ['$..summary', '$..description'],
|
|
46
|
+
};
|
|
47
|
+
default:
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
switch (preset) {
|
|
53
|
+
case 'mintlify':
|
|
54
|
+
return {
|
|
55
|
+
include: ['$..summary', '$..description'],
|
|
56
|
+
};
|
|
57
|
+
case 'openapi':
|
|
58
|
+
return {
|
|
59
|
+
include: ['$..summary', '$..description'],
|
|
60
|
+
};
|
|
61
|
+
default:
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { loadConfig } from '../fs/config/loadConfig.js';
|
|
4
|
+
export function resolveConfig(cwd) {
|
|
5
|
+
const configFilepath = 'gt.config.json';
|
|
6
|
+
if (fs.existsSync(path.join(cwd, configFilepath))) {
|
|
7
|
+
return {
|
|
8
|
+
path: path.join(cwd, configFilepath),
|
|
9
|
+
config: loadConfig(path.join(cwd, configFilepath)),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (fs.existsSync(path.join(cwd, 'src/gt.config.json'))) {
|
|
13
|
+
return {
|
|
14
|
+
path: path.join(cwd, 'src/gt.config.json'),
|
|
15
|
+
config: loadConfig(path.join(cwd, 'src/gt.config.json')),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// Support config under .gt for parity with .locadex
|
|
19
|
+
if (fs.existsSync(path.join(cwd, '.gt/gt.config.json'))) {
|
|
20
|
+
return {
|
|
21
|
+
path: path.join(cwd, '.gt/gt.config.json'),
|
|
22
|
+
config: loadConfig(path.join(cwd, '.gt/gt.config.json')),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Backward compatibility: support legacy .locadex directory
|
|
26
|
+
if (fs.existsSync(path.join(cwd, '.locadex/gt.config.json'))) {
|
|
27
|
+
return {
|
|
28
|
+
path: path.join(cwd, '.locadex/gt.config.json'),
|
|
29
|
+
config: loadConfig(path.join(cwd, '.locadex/gt.config.json')),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isValidLocale, isSupersetLocale } from 'generaltranslation';
|
|
2
|
+
import { logErrorAndExit } from '../console/logging.js';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
export function validateSettings(settings) {
|
|
6
|
+
// Validate locales
|
|
7
|
+
for (const locale of settings.locales) {
|
|
8
|
+
if (!isValidLocale(locale, settings.customMapping)) {
|
|
9
|
+
return logErrorAndExit(`Provided locales: "${settings?.locales?.join()}", ${locale} is not a valid locale!`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (settings.defaultLocale &&
|
|
13
|
+
!isValidLocale(settings.defaultLocale, settings.customMapping)) {
|
|
14
|
+
return logErrorAndExit(`defaultLocale: ${settings.defaultLocale} is not a valid locale!`);
|
|
15
|
+
}
|
|
16
|
+
// defaultLocale cannot be a superset of any other locale
|
|
17
|
+
if (settings.defaultLocale &&
|
|
18
|
+
settings.locales.some((locale) => isSupersetLocale(settings.defaultLocale, locale) &&
|
|
19
|
+
!isSupersetLocale(locale, settings.defaultLocale))) {
|
|
20
|
+
const locale = settings.locales.find((locale) => isSupersetLocale(settings.defaultLocale, locale));
|
|
21
|
+
return logErrorAndExit(`defaultLocale: ${settings.defaultLocale} is a superset of another locale (${locale})! Please change the defaultLocale to a more specific locale.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function validateConfigExists() {
|
|
25
|
+
const possibleConfigPaths = ['gt.config.json', 'src/gt.config.json'];
|
|
26
|
+
for (const possibleConfigPath of possibleConfigPaths) {
|
|
27
|
+
if (fs.existsSync(path.resolve(path.relative(process.cwd(), possibleConfigPath)))) {
|
|
28
|
+
return possibleConfigPath;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return logErrorAndExit('No gt.config.json file found. Are you in the correct directory?');
|
|
32
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function colorizeFilepath(filepath: string): string;
|
|
2
|
+
export declare function colorizeComponent(component: string): string;
|
|
3
|
+
export declare function colorizeFunctionName(functionName: string): string;
|
|
4
|
+
export declare function colorizeIdString(id: string): string;
|
|
5
|
+
export declare function colorizeContent(content: string): string;
|
|
6
|
+
export declare function colorizeLine(line: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export function colorizeFilepath(filepath) {
|
|
3
|
+
return chalk.cyan(filepath);
|
|
4
|
+
}
|
|
5
|
+
export function colorizeComponent(component) {
|
|
6
|
+
return chalk.yellow(component);
|
|
7
|
+
}
|
|
8
|
+
export function colorizeFunctionName(functionName) {
|
|
9
|
+
return chalk.yellow(functionName);
|
|
10
|
+
}
|
|
11
|
+
export function colorizeIdString(id) {
|
|
12
|
+
return chalk.yellow(id);
|
|
13
|
+
}
|
|
14
|
+
export function colorizeContent(content) {
|
|
15
|
+
return chalk.yellow(content);
|
|
16
|
+
}
|
|
17
|
+
export function colorizeLine(line) {
|
|
18
|
+
return chalk.dim(line);
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function displayTranslateSummary(): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { logger } from './logger.js';
|
|
3
|
+
import { getWarnings, hasWarnings, } from '../state/translateWarnings.js';
|
|
4
|
+
const CATEGORY_LABELS = {
|
|
5
|
+
skipped_file: 'Files skipped',
|
|
6
|
+
failed_move: 'File moves failed',
|
|
7
|
+
failed_translation: 'Translations failed',
|
|
8
|
+
failed_download: 'Downloads failed',
|
|
9
|
+
};
|
|
10
|
+
const CATEGORY_ORDER = [
|
|
11
|
+
'skipped_file',
|
|
12
|
+
'failed_move',
|
|
13
|
+
'failed_translation',
|
|
14
|
+
'failed_download',
|
|
15
|
+
];
|
|
16
|
+
export function displayTranslateSummary() {
|
|
17
|
+
if (!hasWarnings())
|
|
18
|
+
return;
|
|
19
|
+
const warnings = getWarnings();
|
|
20
|
+
// Group by category
|
|
21
|
+
const grouped = new Map();
|
|
22
|
+
for (const w of warnings) {
|
|
23
|
+
let list = grouped.get(w.category);
|
|
24
|
+
if (!list) {
|
|
25
|
+
list = [];
|
|
26
|
+
grouped.set(w.category, list);
|
|
27
|
+
}
|
|
28
|
+
list.push({ fileName: w.fileName, reason: w.reason });
|
|
29
|
+
}
|
|
30
|
+
const lines = [chalk.yellow('⚠ Warnings:'), ''];
|
|
31
|
+
for (const category of CATEGORY_ORDER) {
|
|
32
|
+
const items = grouped.get(category);
|
|
33
|
+
if (!items)
|
|
34
|
+
continue;
|
|
35
|
+
lines.push(` ${CATEGORY_LABELS[category]} (${items.length}):`);
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
lines.push(` - ${item.fileName}: ${item.reason}`);
|
|
38
|
+
}
|
|
39
|
+
lines.push('');
|
|
40
|
+
}
|
|
41
|
+
logger.warn(lines.join('\n'));
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatCodeClamp(code: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const warnApiKeyInConfigSync: (optionsFilepath: string) => string;
|
|
2
|
+
export declare const warnVariablePropSync: (file: string, attrName: string, value: string, location?: string) => string;
|
|
3
|
+
export declare const warnInvalidReturnSync: (file: string, functionName: string, expression: string, location?: string) => string;
|
|
4
|
+
export declare const warnMissingReturnSync: (file: string, functionName: string, location?: string) => string;
|
|
5
|
+
export declare const warnHasUnwrappedExpressionSync: (file: string, unwrappedExpressions: string[], id?: string, location?: string) => string;
|
|
6
|
+
export declare const warnFailedToConstructJsxTreeSync: (file: string, code: string, location?: string) => string;
|
|
7
|
+
export declare const warnNestedTComponent: (file: string, location?: string) => string;
|
|
8
|
+
export declare const warnNonStaticExpressionSync: (file: string, attrName: string, value: string, location?: string) => string;
|
|
9
|
+
export declare const warnInvalidMaxCharsSync: (file: string, value: string, location?: string) => string;
|
|
10
|
+
export declare const warnInvalidIcuSync: (file: string, value: string, error: string, location?: string) => string;
|
|
11
|
+
export declare const warnTemplateLiteralSync: (file: string, value: string, location?: string) => string;
|
|
12
|
+
export declare const warnNonStringSync: (file: string, value: string, location?: string) => string;
|
|
13
|
+
export declare const warnAsyncUseGT: (file: string, location?: string) => string;
|
|
14
|
+
export declare const warnSyncGetGT: (file: string, location?: string) => string;
|
|
15
|
+
export declare const warnTernarySync: (file: string, location?: string) => string;
|
|
16
|
+
export declare const withLocation: (file: string, message: string, location?: string) => string;
|
|
17
|
+
export declare const warnFunctionNotFoundSync: (file: string, functionName: string, location?: string) => string;
|
|
18
|
+
export declare const warnInvalidDeclareVarNameSync: (file: string, value: string, location?: string) => string;
|
|
19
|
+
export declare const warnDuplicateFunctionDefinitionSync: (file: string, functionName: string, location?: string) => string;
|
|
20
|
+
export declare const warnInvalidStaticInitSync: (file: string, functionName: string, location?: string) => string;
|
|
21
|
+
export declare const warnDataAttrOnBranch: (file: string, attrName: string, location?: string) => string;
|
|
22
|
+
export declare const warnRecursiveFunctionCallSync: (file: string, functionName: string, location?: string) => string;
|
|
23
|
+
export declare const warnDeclareStaticNotWrappedSync: (file: string, functionName: string, location?: string) => string;
|
|
24
|
+
export declare const warnDeclareStaticNoResultsSync: (file: string, functionName: string, location?: string) => string;
|
|
25
|
+
export declare const noLocalesError = "No locales found! Please provide a list of locales for translation, or specify them in your gt.config.json file.";
|
|
26
|
+
export declare const noDefaultLocaleError = "No default locale found! Please provide a default locale, or specify it in your gt.config.json file.";
|
|
27
|
+
export declare const noFilesError = "Incorrect or missing files configuration! Please make sure your files are configured correctly in your gt.config.json file.";
|
|
28
|
+
export declare const noSourceFileError = "No source file found! Please double check your translations directory and default locale.";
|
|
29
|
+
export declare const noSupportedFormatError = "Unsupported data format! Please make sure your translationsDir parameter ends with a supported file extension.";
|
|
30
|
+
export declare const noApiKeyError = "No API key found! Please provide an API key using the --api-key flag or set the GT_API_KEY environment variable.";
|
|
31
|
+
export declare const devApiKeyError = "You are using a development API key. Please use a production API key to use the General Translation API.\nYou can generate a production API key with the command: npx gt auth -t production";
|
|
32
|
+
export declare const noProjectIdError = "No project ID found! Please provide a project ID using the --project-id flag, specify it in your gt.config.json file, or set the GT_PROJECT_ID environment variable.";
|
|
33
|
+
export declare const noVersionIdError = "No version ID found! Please provide a version ID using the --version-id flag or specify it in your gt.config.json file as the _versionId property.";
|
|
34
|
+
export declare const invalidConfigurationError = "Invalid files configuration! Please either provide a valid configuration to download local translations or set the --publish flag to true to upload translations to the CDN.";
|