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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Libraries } from '../types/libraries.js';
|
|
2
|
+
export function getFrameworkDisplayName(frameworkObject) {
|
|
3
|
+
if (frameworkObject.name === 'mintlify') {
|
|
4
|
+
return 'Mintlify';
|
|
5
|
+
}
|
|
6
|
+
if (frameworkObject.name === 'next-app') {
|
|
7
|
+
return 'Next.js App Router';
|
|
8
|
+
}
|
|
9
|
+
if (frameworkObject.name === 'next-pages') {
|
|
10
|
+
return 'Next.js Pages Router';
|
|
11
|
+
}
|
|
12
|
+
if (frameworkObject.name === 'vite') {
|
|
13
|
+
return 'Vite + React';
|
|
14
|
+
}
|
|
15
|
+
if (frameworkObject.name === 'gatsby') {
|
|
16
|
+
return 'Gatsby';
|
|
17
|
+
}
|
|
18
|
+
if (frameworkObject.name === 'redwood') {
|
|
19
|
+
return 'RedwoodJS';
|
|
20
|
+
}
|
|
21
|
+
if (frameworkObject.type === 'react') {
|
|
22
|
+
return 'React';
|
|
23
|
+
}
|
|
24
|
+
return 'another framework';
|
|
25
|
+
}
|
|
26
|
+
export function getReactFrameworkLibrary(frameworkObject) {
|
|
27
|
+
return frameworkObject.name === 'next-app'
|
|
28
|
+
? Libraries.GT_NEXT
|
|
29
|
+
: Libraries.GT_REACT;
|
|
30
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# General Translation (GT) Internationalization Rules
|
|
2
|
+
|
|
3
|
+
This project is using [General Translation](https://generaltranslation.com/docs/overview.md) for internationalization (i18n) and translations. General Translation is a developer-first localization stack, built for the world's best engineering teams to ship apps in every language with ease.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
The General Translation configuration file is called `gt.config.json`. It is usually located in the root or src directory of a project.
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"defaultLocale": "en",
|
|
12
|
+
"locales": ["es", "fr", "de"],
|
|
13
|
+
"files": {
|
|
14
|
+
"json": {
|
|
15
|
+
"include": ["./**/[locale]/*.json"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The API reference for the config file can be found at <https://generaltranslation.com/docs/cli/reference/config.md>.
|
|
22
|
+
|
|
23
|
+
## Translation
|
|
24
|
+
|
|
25
|
+
Run `npx gt translate` to create translation files for your project. You must have an API key to do this.
|
|
26
|
+
|
|
27
|
+
## Documentation
|
|
28
|
+
|
|
29
|
+
<https://generaltranslation.com/llms.txt>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# gt-next
|
|
2
|
+
|
|
3
|
+
This project is using the `gt-next` internationalization library for Next.js App Router.
|
|
4
|
+
|
|
5
|
+
## gt-next setup
|
|
6
|
+
|
|
7
|
+
- `GTProvider` must wrap the app in the root layout to provide translation context.
|
|
8
|
+
- The `withGTConfig()` plugin wraps `next.config` in the Next.js config file.
|
|
9
|
+
- (optional) `createNextMiddleware()` is used in `proxy.ts` for automatic locale routing.
|
|
10
|
+
|
|
11
|
+
## Translating JSX
|
|
12
|
+
|
|
13
|
+
`gt-next` uses the `<T>` component for translation.
|
|
14
|
+
|
|
15
|
+
Pass JSX content as the direct children of `<T>` to translate it. Children of `<T>` must be static — no JS expressions or variables directly inside.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { T } from 'gt-next';
|
|
19
|
+
|
|
20
|
+
<T>
|
|
21
|
+
<h1>Welcome to our store</h1>
|
|
22
|
+
<p>
|
|
23
|
+
Browse our <a href='/products'>latest products</a> and find something you
|
|
24
|
+
love.
|
|
25
|
+
</p>
|
|
26
|
+
</T>;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You can also add a `context` prop to `<T>` to give context to the translator. For example:
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
import { T } from 'gt-next';
|
|
33
|
+
|
|
34
|
+
<T context="Cookies as in web cookies">
|
|
35
|
+
View your <a href="/cookies">Cookies</a>
|
|
36
|
+
</T>;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Translating simple strings
|
|
40
|
+
|
|
41
|
+
Use the `gt` function returned by the `useGT()` hook to translate strings directly. Invoke `useGT()` in synchronous components or `await getGT()` in async components only.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { useGT } from 'gt-next';
|
|
45
|
+
const gt = useGT();
|
|
46
|
+
gt('Hello, world!'); // returns "Hola, mundo"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import { getGT } from 'gt-next/server';
|
|
51
|
+
const gt = await getGT(); // use await version in async components only
|
|
52
|
+
gt('Hello, world!');
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- Just like with the children of the `<T>` component, all strings passed to `gt()` must be static string literals. No variables or template literals.
|
|
56
|
+
|
|
57
|
+
## Translating shared or out-of-scope strings
|
|
58
|
+
|
|
59
|
+
Use `msg()` to register strings for translation, and `useMessages()` to translate them. `const m = useMessages()` should be used equivalently to `const gt = useGT()`.
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import { msg, useMessages } from 'gt-next';
|
|
63
|
+
|
|
64
|
+
const greeting = msg('Hello, world!');
|
|
65
|
+
|
|
66
|
+
export default function Greeting() {
|
|
67
|
+
const m = useMessages();
|
|
68
|
+
return <p>{m(greeting)}</p>;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- All strings passed to `msg()` must be static string literals. No variables or template literals.
|
|
73
|
+
- Use the equivalent `await getMessages()` for async components.
|
|
74
|
+
- `useMessages()` / `getMessages()` take no arguments.
|
|
75
|
+
|
|
76
|
+
## Dynamic content inside `<T>`
|
|
77
|
+
|
|
78
|
+
Use variable components for dynamic values inside `<T>`:
|
|
79
|
+
|
|
80
|
+
- `<Var>{value}</Var>` — variables (strings, numbers, etc.)
|
|
81
|
+
- `<Num>{value}</Num>` — formatted numbers
|
|
82
|
+
- `<Currency>{value}</Currency>` — formatted currency
|
|
83
|
+
- `<DateTime>{value}</DateTime>` — formatted dates/times
|
|
84
|
+
|
|
85
|
+
```jsx
|
|
86
|
+
import { T, Var, Num } from 'gt-next';
|
|
87
|
+
|
|
88
|
+
<T>
|
|
89
|
+
<Var>{userName}</Var> ordered <Num>{itemCount}</Num> items.
|
|
90
|
+
</T>;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Utility hooks
|
|
94
|
+
|
|
95
|
+
### `useLocale()`
|
|
96
|
+
|
|
97
|
+
`useLocale` returns the user's current language, as a BCP 47 locale tag.
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
import { useLocale } from 'gt-next'
|
|
101
|
+
|
|
102
|
+
const locale = useLocale(); // "en-US"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Quickstart
|
|
106
|
+
|
|
107
|
+
See <https://generaltranslation.com/docs/next.md>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# gt-react
|
|
2
|
+
|
|
3
|
+
This project is using the `gt-react` internationalization library.
|
|
4
|
+
|
|
5
|
+
## gt-react setup
|
|
6
|
+
|
|
7
|
+
- `GTProvider` must wrap the app in the root layout to provide translation context.
|
|
8
|
+
|
|
9
|
+
## Translating JSX
|
|
10
|
+
|
|
11
|
+
`gt-react` uses the `<T>` component for translation.
|
|
12
|
+
|
|
13
|
+
Pass JSX content as the direct children of `<T>` to translate it. Children of `<T>` must be static — no JS expressions or variables directly inside.
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import { T } from 'gt-react';
|
|
17
|
+
|
|
18
|
+
<T>
|
|
19
|
+
<h1>Welcome to our store</h1>
|
|
20
|
+
<p>
|
|
21
|
+
Browse our <a href='/products'>latest products</a> and find something you
|
|
22
|
+
love.
|
|
23
|
+
</p>
|
|
24
|
+
</T>;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
You can also add a `context` prop to `<T>` to give context to the translator. For example:
|
|
28
|
+
|
|
29
|
+
```jsx
|
|
30
|
+
import { T } from 'gt-react';
|
|
31
|
+
|
|
32
|
+
<T context="Cookies as in web cookies">
|
|
33
|
+
View your <a href="/cookies">Cookies</a>
|
|
34
|
+
</T>;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Translating simple strings
|
|
38
|
+
|
|
39
|
+
Use the `gt` function returned by the `useGT()` hook to translate strings directly.
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { useGT } from 'gt-react';
|
|
43
|
+
const gt = useGT();
|
|
44
|
+
gt('Hello, world!'); // returns "Hola, mundo"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- Just like with the children of the `<T>` component, all strings passed to `gt()` must be static string literals. No variables or template literals.
|
|
48
|
+
|
|
49
|
+
## Translating shared or out-of-scope strings
|
|
50
|
+
|
|
51
|
+
Use `msg()` to register strings for translation, and `useMessages()` to translate them. `const m = useMessages()` should be used equivalently to `const gt = useGT()`.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { msg, useMessages } from 'gt-react';
|
|
55
|
+
|
|
56
|
+
const greeting = msg('Hello, world!');
|
|
57
|
+
|
|
58
|
+
export default function Greeting() {
|
|
59
|
+
const m = useMessages();
|
|
60
|
+
return <p>{m(greeting)}</p>;
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- All strings passed to `msg()` must be static string literals. No variables or template literals.
|
|
65
|
+
- `useMessages()` / `getMessages()` take no arguments.
|
|
66
|
+
|
|
67
|
+
## Dynamic content inside `<T>`
|
|
68
|
+
|
|
69
|
+
Use variable components for dynamic values inside `<T>`:
|
|
70
|
+
|
|
71
|
+
- `<Var>{value}</Var>` — variables (strings, numbers, etc.)
|
|
72
|
+
- `<Num>{value}</Num>` — formatted numbers
|
|
73
|
+
- `<Currency>{value}</Currency>` — formatted currency
|
|
74
|
+
- `<DateTime>{value}</DateTime>` — formatted dates/times
|
|
75
|
+
|
|
76
|
+
```jsx
|
|
77
|
+
import { T, Var, Num } from 'gt-react';
|
|
78
|
+
|
|
79
|
+
<T>
|
|
80
|
+
<Var>{userName}</Var> ordered <Num>{itemCount}</Num> items.
|
|
81
|
+
</T>;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Utility hooks
|
|
85
|
+
|
|
86
|
+
### `useLocale()`
|
|
87
|
+
|
|
88
|
+
`useLocale` returns the user's current language, as a BCP 47 locale tag.
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
import { useLocale } from 'gt-react'
|
|
92
|
+
|
|
93
|
+
const locale = useLocale(); // "en-US"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Quickstart
|
|
97
|
+
|
|
98
|
+
See <https://generaltranslation.com/docs/react.md>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { libraryDefaultLocale } from 'generaltranslation/internal';
|
|
2
|
+
import { promptText } from '../console/logging.js';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { gt } from '../utils/gt.js';
|
|
5
|
+
export async function getDesiredLocales() {
|
|
6
|
+
// Ask for the default locale
|
|
7
|
+
const defaultLocale = await promptText({
|
|
8
|
+
message: 'What is the default locale for your project?',
|
|
9
|
+
defaultValue: libraryDefaultLocale,
|
|
10
|
+
});
|
|
11
|
+
// Ask for the locales
|
|
12
|
+
const locales = await promptText({
|
|
13
|
+
message: `Which languages would you like to translate your project into? Enter your response as a list of BCP-47 locale tags. ${chalk.dim('(space-separated list)')}`,
|
|
14
|
+
defaultValue: 'es fr de ja zh',
|
|
15
|
+
validate: (input) => {
|
|
16
|
+
const localeList = input.split(' ');
|
|
17
|
+
if (localeList.length === 0) {
|
|
18
|
+
return 'Please enter at least one locale';
|
|
19
|
+
}
|
|
20
|
+
if (localeList.some((locale) => !locale.trim())) {
|
|
21
|
+
return 'Please enter a valid locale (e.g., es fr de)';
|
|
22
|
+
}
|
|
23
|
+
for (const locale of localeList) {
|
|
24
|
+
if (!gt.isValidLocale(locale)) {
|
|
25
|
+
return 'Please enter a valid locale (e.g., es fr de)';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return { defaultLocale, locales: locales.split(' ') };
|
|
32
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { detectFormatter } from '../hooks/postProcess.js';
|
|
2
|
+
import { promptSelect } from '../console/logging.js';
|
|
3
|
+
import { logger } from '../console/logger.js';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { promptConfirm } from '../console/logging.js';
|
|
6
|
+
import findFilepath from '../fs/findFilepath.js';
|
|
7
|
+
import { formatFiles } from '../hooks/postProcess.js';
|
|
8
|
+
import { handleInitGT } from '../next/parse/handleInitGT.js';
|
|
9
|
+
import { getPackageJson, isPackageInstalled } from '../utils/packageJson.js';
|
|
10
|
+
import { wrapContentNext } from '../next/parse/wrapContent.js';
|
|
11
|
+
import { getPackageManager } from '../utils/packageManager.js';
|
|
12
|
+
import { installPackage } from '../utils/installPackage.js';
|
|
13
|
+
import { createOrUpdateConfig } from '../fs/config/setupConfig.js';
|
|
14
|
+
import { loadConfig } from '../fs/config/loadConfig.js';
|
|
15
|
+
import { addVitePlugin } from '../react/parse/addVitePlugin/index.js';
|
|
16
|
+
import { exitSync } from '../console/logging.js';
|
|
17
|
+
import { getFrameworkDisplayName } from './frameworkUtils.js';
|
|
18
|
+
import { Libraries } from '../types/libraries.js';
|
|
19
|
+
export async function handleSetupReactCommand(options, frameworkObject, useDefaults = false) {
|
|
20
|
+
const frameworkDisplayName = getFrameworkDisplayName(frameworkObject);
|
|
21
|
+
// Ask user for confirmation using inquirer
|
|
22
|
+
if (!useDefaults) {
|
|
23
|
+
const answer = await promptConfirm({
|
|
24
|
+
message: chalk.yellow(`This wizard will configure your ${frameworkDisplayName} project for internationalization with GT. If your project is already using a different i18n library, this wizard may cause issues.
|
|
25
|
+
|
|
26
|
+
Make sure you have committed or stashed any changes. Do you want to continue?`),
|
|
27
|
+
defaultValue: true,
|
|
28
|
+
cancelMessage: 'Operation cancelled. You can re-run this wizard with: npx gt setup',
|
|
29
|
+
});
|
|
30
|
+
if (!answer) {
|
|
31
|
+
logger.info('Operation cancelled. You can re-run this wizard with: npx gt setup');
|
|
32
|
+
exitSync(0);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const frameworkType = useDefaults && frameworkObject?.name
|
|
36
|
+
? frameworkObject.name
|
|
37
|
+
: await promptSelect({
|
|
38
|
+
message: 'Which framework are you using?',
|
|
39
|
+
options: [
|
|
40
|
+
{ value: 'next-app', label: chalk.blue('Next.js App Router') },
|
|
41
|
+
{ value: 'next-pages', label: chalk.green('Next.js Pages Router') },
|
|
42
|
+
{ value: 'vite', label: chalk.cyan('Vite + React') },
|
|
43
|
+
{ value: 'gatsby', label: chalk.magenta('Gatsby') },
|
|
44
|
+
{ value: 'react', label: chalk.yellow('React') },
|
|
45
|
+
{ value: 'redwood', label: chalk.red('RedwoodJS') },
|
|
46
|
+
{ value: 'other', label: chalk.dim('Other') },
|
|
47
|
+
],
|
|
48
|
+
defaultValue: frameworkObject?.name || 'other',
|
|
49
|
+
});
|
|
50
|
+
if (frameworkType === 'other') {
|
|
51
|
+
logger.error(`Sorry, the wizard doesn't currently support other React frameworks.
|
|
52
|
+
Please let us know what you would like to see added at https://github.com/generaltranslation/gt/issues`);
|
|
53
|
+
exitSync(0);
|
|
54
|
+
}
|
|
55
|
+
// ----- Create a starter gt.config.json file -----
|
|
56
|
+
await createOrUpdateConfig(options.config || 'gt.config.json', {
|
|
57
|
+
framework: frameworkType,
|
|
58
|
+
});
|
|
59
|
+
const packageJson = await getPackageJson();
|
|
60
|
+
if (!packageJson) {
|
|
61
|
+
logger.error(chalk.red('No package.json found in the current directory. Please run this command from the root of your project.'));
|
|
62
|
+
exitSync(1);
|
|
63
|
+
}
|
|
64
|
+
// Check if gt-next or gt-react is installed
|
|
65
|
+
if (frameworkType === 'next-app' &&
|
|
66
|
+
!isPackageInstalled(Libraries.GT_NEXT, packageJson)) {
|
|
67
|
+
const packageManager = await getPackageManager();
|
|
68
|
+
const spinner = logger.createSpinner('timer');
|
|
69
|
+
spinner.start(`Installing ${Libraries.GT_NEXT} with ${packageManager.name}...`);
|
|
70
|
+
await installPackage(Libraries.GT_NEXT, packageManager);
|
|
71
|
+
spinner.stop(chalk.green(`Automatically installed ${Libraries.GT_NEXT}.`));
|
|
72
|
+
}
|
|
73
|
+
else if (['next-pages', 'react', 'redwood', 'vite', 'gatsby'].includes(frameworkType) &&
|
|
74
|
+
!isPackageInstalled(Libraries.GT_REACT, packageJson)) {
|
|
75
|
+
const packageManager = await getPackageManager();
|
|
76
|
+
const spinner = logger.createSpinner('timer');
|
|
77
|
+
spinner.start(`Installing ${Libraries.GT_REACT} with ${packageManager.name}...`);
|
|
78
|
+
await installPackage(Libraries.GT_REACT, packageManager);
|
|
79
|
+
spinner.stop(chalk.green(`Automatically installed ${Libraries.GT_REACT}.`));
|
|
80
|
+
}
|
|
81
|
+
const errors = [];
|
|
82
|
+
const warnings = [];
|
|
83
|
+
let filesUpdated = [];
|
|
84
|
+
// Read tsconfig.json if it exists
|
|
85
|
+
const tsconfigPath = findFilepath(['tsconfig.json']);
|
|
86
|
+
const tsconfigJson = tsconfigPath ? loadConfig(tsconfigPath) : undefined;
|
|
87
|
+
if (frameworkType === 'next-app') {
|
|
88
|
+
// Check if they have a next.config.js file
|
|
89
|
+
const nextConfigPath = findFilepath([
|
|
90
|
+
'./next.config.js',
|
|
91
|
+
'./next.config.ts',
|
|
92
|
+
'./next.config.mjs',
|
|
93
|
+
'./next.config.mts',
|
|
94
|
+
]);
|
|
95
|
+
if (!nextConfigPath) {
|
|
96
|
+
logger.error('No next.config.[js|ts|mjs|mts] file found.');
|
|
97
|
+
exitSync(1);
|
|
98
|
+
}
|
|
99
|
+
const mergeOptions = {
|
|
100
|
+
...options,
|
|
101
|
+
disableIds: true,
|
|
102
|
+
disableFormatting: true,
|
|
103
|
+
skipTs: true,
|
|
104
|
+
addGTProvider: true,
|
|
105
|
+
};
|
|
106
|
+
const spinner = logger.createSpinner();
|
|
107
|
+
spinner.start('Wrapping JSX content with <T> tags...');
|
|
108
|
+
// Wrap all JSX elements in the src directory with a <T> tag, with unique ids
|
|
109
|
+
const { filesUpdated: filesUpdatedNext } = await wrapContentNext(mergeOptions, Libraries.GT_NEXT, errors, warnings);
|
|
110
|
+
filesUpdated = [...filesUpdated, ...filesUpdatedNext];
|
|
111
|
+
spinner.stop(chalk.green(`Success! Updated ${chalk.bold.cyan(filesUpdated.length)} files:\n`) + filesUpdated.map((file) => `${chalk.green('-')} ${file}`).join('\n'));
|
|
112
|
+
// Add the withGTConfig() function to the next.config.js file
|
|
113
|
+
await handleInitGT(nextConfigPath, errors, warnings, filesUpdated, packageJson, tsconfigJson);
|
|
114
|
+
logger.step(chalk.green(`Added withGTConfig() to your ${nextConfigPath} file.`));
|
|
115
|
+
}
|
|
116
|
+
// Add gt compiler plugin
|
|
117
|
+
if (frameworkType === 'vite') {
|
|
118
|
+
await addVitePlugin({
|
|
119
|
+
errors,
|
|
120
|
+
warnings,
|
|
121
|
+
filesUpdated,
|
|
122
|
+
packageJson,
|
|
123
|
+
tsconfigJson,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (errors.length > 0) {
|
|
127
|
+
logger.error(chalk.red('Failed to write files:\n') + errors.join('\n'));
|
|
128
|
+
}
|
|
129
|
+
if (warnings.length > 0) {
|
|
130
|
+
logger.warn(chalk.yellow('Warnings encountered:') +
|
|
131
|
+
'\n' +
|
|
132
|
+
warnings.map((warning) => `${chalk.yellow('-')} ${warning}`).join('\n'));
|
|
133
|
+
}
|
|
134
|
+
const formatter = await detectFormatter();
|
|
135
|
+
if (!formatter || filesUpdated.length === 0) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const applyFormatting = useDefaults
|
|
139
|
+
? true
|
|
140
|
+
: await promptConfirm({
|
|
141
|
+
message: `Would you like the wizard to auto-format the modified files? ${chalk.dim(`(${formatter})`)}`,
|
|
142
|
+
defaultValue: true,
|
|
143
|
+
});
|
|
144
|
+
// Format updated files if formatters are available
|
|
145
|
+
if (applyFormatting)
|
|
146
|
+
await formatFiles(filesUpdated, formatter);
|
|
147
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type DownloadMeta = {
|
|
2
|
+
branchId: string;
|
|
3
|
+
fileId: string;
|
|
4
|
+
versionId: string;
|
|
5
|
+
locale: string;
|
|
6
|
+
inputPath?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function recordDownloaded(filePath: string, meta?: DownloadMeta): void;
|
|
9
|
+
export declare function getDownloaded(): Set<string>;
|
|
10
|
+
export declare function getDownloadedMeta(): Map<string, DownloadMeta>;
|
|
11
|
+
export declare function clearDownloaded(): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const recent = new Set();
|
|
2
|
+
const recentMeta = new Map();
|
|
3
|
+
export function recordDownloaded(filePath, meta) {
|
|
4
|
+
recent.add(filePath);
|
|
5
|
+
if (meta) {
|
|
6
|
+
recentMeta.set(filePath, meta);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function getDownloaded() {
|
|
10
|
+
return recent;
|
|
11
|
+
}
|
|
12
|
+
export function getDownloadedMeta() {
|
|
13
|
+
return recentMeta;
|
|
14
|
+
}
|
|
15
|
+
export function clearDownloaded() {
|
|
16
|
+
recent.clear();
|
|
17
|
+
recentMeta.clear();
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type WarningCategory = 'skipped_file' | 'failed_move' | 'failed_translation' | 'failed_download';
|
|
2
|
+
export type TranslateWarning = {
|
|
3
|
+
category: WarningCategory;
|
|
4
|
+
fileName: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function recordWarning(category: WarningCategory, fileName: string, reason: string): void;
|
|
8
|
+
export declare function getWarnings(): TranslateWarning[];
|
|
9
|
+
export declare function hasWarnings(): boolean;
|
|
10
|
+
export declare function clearWarnings(): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const warnings = [];
|
|
2
|
+
export function recordWarning(category, fileName, reason) {
|
|
3
|
+
warnings.push({ category, fileName, reason });
|
|
4
|
+
}
|
|
5
|
+
export function getWarnings() {
|
|
6
|
+
return warnings;
|
|
7
|
+
}
|
|
8
|
+
export function hasWarnings() {
|
|
9
|
+
return warnings.length > 0;
|
|
10
|
+
}
|
|
11
|
+
export function clearWarnings() {
|
|
12
|
+
warnings.length = 0;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Updates, TranslateFlags } from '../types/index.js';
|
|
2
|
+
import type { ParsingConfigOptions } from '../types/parsing.js';
|
|
3
|
+
import { InlineLibrary } from '../types/libraries.js';
|
|
4
|
+
/**
|
|
5
|
+
* Searches for gt-react or gt-next dictionary files and creates updates for them,
|
|
6
|
+
* as well as inline updates for <T> tags and useGT()/getGT() calls
|
|
7
|
+
*
|
|
8
|
+
* @param options - The options object
|
|
9
|
+
* @param sourceDictionary - The source dictionary file path
|
|
10
|
+
* @param pkg - The package name
|
|
11
|
+
* @returns An object containing the updates and errors
|
|
12
|
+
*/
|
|
13
|
+
export declare function createUpdates(options: TranslateFlags, src: string[] | undefined, sourceDictionary: string | undefined, pkg: InlineLibrary, validate: boolean, parsingOptions: ParsingConfigOptions): Promise<{
|
|
14
|
+
updates: Updates;
|
|
15
|
+
errors: string[];
|
|
16
|
+
warnings: string[];
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { logger } from '../console/logger.js';
|
|
3
|
+
import loadJSON from '../fs/loadJSON.js';
|
|
4
|
+
import { createDictionaryUpdates } from '../react/parse/createDictionaryUpdates.js';
|
|
5
|
+
import { createInlineUpdates } from '../react/parse/createInlineUpdates.js';
|
|
6
|
+
import createESBuildConfig from '../react/config/createESBuildConfig.js';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { exitSync } from '../console/logging.js';
|
|
9
|
+
/**
|
|
10
|
+
* Searches for gt-react or gt-next dictionary files and creates updates for them,
|
|
11
|
+
* as well as inline updates for <T> tags and useGT()/getGT() calls
|
|
12
|
+
*
|
|
13
|
+
* @param options - The options object
|
|
14
|
+
* @param sourceDictionary - The source dictionary file path
|
|
15
|
+
* @param pkg - The package name
|
|
16
|
+
* @returns An object containing the updates and errors
|
|
17
|
+
*/
|
|
18
|
+
export async function createUpdates(options, src, sourceDictionary, pkg, validate, parsingOptions) {
|
|
19
|
+
let updates = [];
|
|
20
|
+
let errors = [];
|
|
21
|
+
let warnings = [];
|
|
22
|
+
// Parse dictionary with esbuildConfig
|
|
23
|
+
if (sourceDictionary &&
|
|
24
|
+
fs.existsSync(sourceDictionary) &&
|
|
25
|
+
fs.statSync(sourceDictionary).isFile()) {
|
|
26
|
+
if (sourceDictionary.endsWith('.json')) {
|
|
27
|
+
updates = [
|
|
28
|
+
...updates,
|
|
29
|
+
...(await createDictionaryUpdates(sourceDictionary, errors, warnings)),
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
let esbuildConfig;
|
|
34
|
+
if (options.jsconfig) {
|
|
35
|
+
const jsconfig = loadJSON(options.jsconfig);
|
|
36
|
+
if (!jsconfig) {
|
|
37
|
+
logger.error(`Failed to resolve jsconfig.json or tsconfig.json at provided filepath: "${options.jsconfig}"`);
|
|
38
|
+
exitSync(1);
|
|
39
|
+
}
|
|
40
|
+
esbuildConfig = createESBuildConfig(jsconfig);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
esbuildConfig = createESBuildConfig({});
|
|
44
|
+
}
|
|
45
|
+
updates = [
|
|
46
|
+
...updates,
|
|
47
|
+
...(await createDictionaryUpdates(sourceDictionary, errors, warnings, esbuildConfig)),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Scan through project for <T> tags
|
|
52
|
+
const { updates: newUpdates, errors: newErrors, warnings: newWarnings, } = await createInlineUpdates(pkg, validate, src, parsingOptions);
|
|
53
|
+
errors = [...errors, ...newErrors];
|
|
54
|
+
warnings = [...warnings, ...newWarnings];
|
|
55
|
+
updates = [...updates, ...newUpdates];
|
|
56
|
+
// Metadata addition and validation
|
|
57
|
+
const idHashMap = new Map();
|
|
58
|
+
const duplicateIds = new Set();
|
|
59
|
+
updates = updates.map((update) => {
|
|
60
|
+
if (!update.metadata.id)
|
|
61
|
+
return update;
|
|
62
|
+
const existingHash = idHashMap.get(update.metadata.id);
|
|
63
|
+
if (existingHash) {
|
|
64
|
+
if (existingHash !== update.metadata.hash) {
|
|
65
|
+
errors.push(`Hashes don't match on two components with the same id: ${chalk.blue(update.metadata.id)}. Check your ${chalk.green('<T>')} tags and dictionary entries and make sure you're not accidentally duplicating IDs.`);
|
|
66
|
+
duplicateIds.add(update.metadata.id);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
idHashMap.set(update.metadata.id, update.metadata.hash);
|
|
71
|
+
}
|
|
72
|
+
return update;
|
|
73
|
+
});
|
|
74
|
+
// Filter out updates with duplicate IDs
|
|
75
|
+
updates = updates.filter((update) => !duplicateIds.has(update.metadata.id));
|
|
76
|
+
return { updates, errors, warnings };
|
|
77
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { logErrorAndExit } from '../console/logging.js';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import findFilepath from '../fs/findFilepath.js';
|
|
4
|
+
import { logger } from '../console/logger.js';
|
|
5
|
+
import { createUpdates } from './parse.js';
|
|
6
|
+
export async function aggregateInlineTranslations(options, settings, library) {
|
|
7
|
+
if (!options.dictionary) {
|
|
8
|
+
options.dictionary = findFilepath([
|
|
9
|
+
'./dictionary.js',
|
|
10
|
+
'./src/dictionary.js',
|
|
11
|
+
'./dictionary.json',
|
|
12
|
+
'./src/dictionary.json',
|
|
13
|
+
'./dictionary.ts',
|
|
14
|
+
'./src/dictionary.ts',
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
// ---- CREATING UPDATES ---- //
|
|
18
|
+
const { updates, errors, warnings } = await createUpdates(options, settings.src, options.dictionary, library, false, settings.parsingOptions);
|
|
19
|
+
if (warnings.length > 0) {
|
|
20
|
+
logger.warn(chalk.yellow(`CLI tool encountered ${warnings.length} warnings while scanning for translatable content.\n` +
|
|
21
|
+
warnings
|
|
22
|
+
.map((warning) => chalk.yellow('• Warning: ') + chalk.white(warning))
|
|
23
|
+
.join('\n')));
|
|
24
|
+
}
|
|
25
|
+
if (errors.length > 0) {
|
|
26
|
+
if (options.ignoreErrors) {
|
|
27
|
+
logger.warn(chalk.yellow(`Warning: CLI tool encountered ${errors.length} syntax errors while scanning for translatable content. These components will not be translated.\n` +
|
|
28
|
+
errors
|
|
29
|
+
.map((error) => chalk.yellow('• ') + chalk.white(error) + '\n')
|
|
30
|
+
.join('')));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
logErrorAndExit(chalk.red(`Error: CLI tool encountered ${errors.length} syntax errors while scanning for translatable content. ${chalk.gray('To ignore these errors, re-run with --ignore-errors')}\n` +
|
|
34
|
+
errors
|
|
35
|
+
.map((error) => chalk.red('• ') + chalk.white(error) + '\n')
|
|
36
|
+
.join('')));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (updates.length == 0) {
|
|
40
|
+
logger.error(chalk.red(`No in-line content or dictionaries were found for ${chalk.green(library)}. Are you sure you're running this command in the right directory?`));
|
|
41
|
+
return updates;
|
|
42
|
+
}
|
|
43
|
+
return updates;
|
|
44
|
+
}
|