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/LICENSE.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2025 General Translation, Inc.
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,211 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
[gt-ci-image]: https://travis-ci.org/bahmutov/gt.png?branch=master
|
|
15
|
-
[gt-ci-url]: https://travis-ci.org/bahmutov/gt
|
|
16
|
-
[gt-coverage-image]: https://coveralls.io/repos/bahmutov/gt/badge.png
|
|
17
|
-
[gt-coverage-url]: https://coveralls.io/r/bahmutov/gt
|
|
18
|
-
[gt-dependencies-image]: https://david-dm.org/bahmutov/gt.png
|
|
19
|
-
[gt-dependencies-url]: https://david-dm.org/bahmutov/gt
|
|
20
|
-
[gt-devdependencies-image]: https://david-dm.org/bahmutov/gt/dev-status.png
|
|
21
|
-
[gt-devdependencies-url]: https://david-dm.org/bahmutov/gt#info=devDependencies
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## Install and run
|
|
26
|
-
|
|
27
|
-
**gt** requires *nodejs* and a few modules to run. Assuming you wrote a few qunit tests in tests.js:
|
|
28
|
-
|
|
29
|
-
```sh
|
|
30
|
-
sudo npm install -g gt
|
|
31
|
-
gt tests.js
|
|
32
|
-
|
|
33
|
-
some of the options (-h for all):
|
|
34
|
-
-l <debug level> 0 = debug, 1 = default, 2 = warnings, 3 = errors
|
|
35
|
-
-r <report level> 0 = all (default), 1 = failed tests only
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Goals
|
|
40
|
-
|
|
41
|
-
1. Make sure QUnit tests work with [istanbul](https://github.com/gotwarlost/istanbul "Istanbul at GitHub") JS coverage tool
|
|
42
|
-
2. Experiment with JS unit testing by writing a framework from scratch.
|
|
43
|
-
|
|
44
|
-
### Example
|
|
45
|
-
|
|
46
|
-
A simple example is in [examples subfolder](gt/tree/master/examples/basic "gt Examples")
|
|
47
|
-
|
|
48
|
-
Unit tests follow QUnit approach:
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://generaltranslation.com/docs/cli">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://generaltranslation.com/gt-logo-dark.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://generaltranslation.com/gt-logo-light.svg">
|
|
6
|
+
<img alt="General Translation" src="https://generaltranslation.com/gt-logo-light.svg" width="100" height="100">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://generaltranslation.com/docs/cli"><strong>Documentation</strong></a> · <a href="https://github.com/generaltranslation/gt/issues">Report Bug</a>
|
|
13
|
+
</p>
|
|
49
14
|
|
|
50
|
-
|
|
51
|
-
gt.module("Basic tests");
|
|
52
|
-
|
|
53
|
-
gt.test("get N '='", function () {
|
|
54
|
-
gt.ok(typeof getLines === "function", "getLines is a function");
|
|
55
|
-
gt.equal(getLines(0), "", "0 character");
|
|
56
|
-
gt.equal(getLines(1), "=", "1 character");
|
|
57
|
-
});
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Creates unit test report (stdout only) and JS code coverage (stdout plus Lines of Code + HTML in folder cover)
|
|
61
|
-
|
|
62
|
-
gt ./examples/basic/tests ./examples/basic/exceptionTests
|
|
63
|
-
|
|
64
|
-
Sample unit test output [image](gt/blob/master/examples/example.png "Console screenshot")
|
|
65
|
-
|
|
66
|
-
Sample JS coverage output [image](gt/blob/master/examples/coverage.png "Coverage page screenshot")
|
|
67
|
-
|
|
68
|
-
### CoffeeScript support
|
|
69
|
-
|
|
70
|
-
You can write your unit tests using [coffeescript](http://coffeescript.org/), which allows very concise code.
|
|
71
|
-
So far, the code coverage does not include the unit test files themselves, they will be omitted from the coverage report.
|
|
72
|
-
See *examples/coffee* folder.
|
|
73
|
-
|
|
74
|
-
### Running in browser
|
|
75
|
-
|
|
76
|
-
See example **examples/browser**
|
|
77
|
-
|
|
78
|
-
### BDD support
|
|
79
|
-
|
|
80
|
-
gt provides minimal BDD support and can run Mocha/Jasmine specs that have `describe` and `it` calls.
|
|
81
|
-
See [spec example](examples/bdd/spec.js). You can run it using `gt --bdd spec.js` command.
|
|
82
|
-
|
|
83
|
-
## API
|
|
84
|
-
|
|
85
|
-
### module
|
|
86
|
-
|
|
87
|
-
Creates new suite of tests with given name
|
|
15
|
+
# gt
|
|
88
16
|
|
|
89
|
-
|
|
90
|
-
gt.module('math tests');
|
|
91
|
-
```
|
|
17
|
+
Command-line tool for General Translation's i18n platform.
|
|
92
18
|
|
|
93
|
-
|
|
94
|
-
each unit tests. You can also specify a function to run once
|
|
95
|
-
before any tests, and after all tests.
|
|
19
|
+
## Installation
|
|
96
20
|
|
|
97
|
-
```
|
|
98
|
-
gt
|
|
99
|
-
setupOnce: function () {
|
|
100
|
-
// setup server
|
|
101
|
-
},
|
|
102
|
-
setup: function () {
|
|
103
|
-
// clear data before each unit test
|
|
104
|
-
},
|
|
105
|
-
teardown: function () {
|
|
106
|
-
// clean up after each unit test
|
|
107
|
-
},
|
|
108
|
-
teardownOnce: function () {
|
|
109
|
-
// stop server
|
|
110
|
-
}
|
|
111
|
-
});
|
|
21
|
+
```bash
|
|
22
|
+
npm install gt --save-dev
|
|
112
23
|
```
|
|
113
24
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
A very convenient feature: each method can return a promise object
|
|
117
|
-
to tell the test engine when it is done. See [example](examples/async/asyncSetup.js)
|
|
25
|
+
## Quick Start
|
|
118
26
|
|
|
27
|
+
Set up your project:
|
|
119
28
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
Spawns new proces, waits for it to finish, then
|
|
124
|
-
checks the exit code. Automatically restarts the test queue
|
|
125
|
-
|
|
126
|
-
**Checking just the exit code**
|
|
127
|
-
|
|
128
|
-
```js
|
|
129
|
-
gt.async('run Nodejs program', function () {
|
|
130
|
-
gt.exec('node', ['index.js', 'arg1', 'arg2'], 0,
|
|
131
|
-
'expect "node index.js arg1 arg2" to exit with code 0');
|
|
132
|
-
});
|
|
29
|
+
```bash
|
|
30
|
+
npx gt init
|
|
133
31
|
```
|
|
134
32
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
```js
|
|
138
|
-
gt.async('run a program', function () {
|
|
139
|
-
gt.exec('node', ['index.js', 'arg1', 'arg2'], 0,
|
|
140
|
-
function (stdout, stderr) {
|
|
141
|
-
if (/error/.test(stdout)) {
|
|
142
|
-
throw new Error('Errors in output ' + stdout);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Full [exec unit test](examples/exec/tests.js)
|
|
149
|
-
|
|
150
|
-
**shortcuts:**
|
|
151
|
-
|
|
152
|
-
```js
|
|
153
|
-
gt.exec(cmd, [...], 'msg');
|
|
154
|
-
// same as
|
|
155
|
-
gt.exec(cmd, [...], 0, 'msg');
|
|
33
|
+
Generate translations:
|
|
156
34
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
gt.exec(cmd, [], 0, msg);
|
|
160
|
-
|
|
161
|
-
gt.exec(cmd);
|
|
162
|
-
// same as
|
|
163
|
-
gt.exec(cmd, [], 0);
|
|
35
|
+
```bash
|
|
36
|
+
npx gt translate
|
|
164
37
|
```
|
|
165
38
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
### gt.equiv
|
|
169
|
-
|
|
170
|
-
Performs deep equality comparison between two objects.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
## command line options
|
|
179
|
-
|
|
180
|
-
### --no-cover part-of-path
|
|
181
|
-
|
|
182
|
-
gt excludes certain common paths from coverage,
|
|
183
|
-
speeding up the test runs: node_modules, bower_components, etc.
|
|
184
|
-
You can add paths to this list, for example to exclude all files
|
|
185
|
-
loaded from `vendor` folders:
|
|
186
|
-
|
|
187
|
-
gt --no-cover vendor src/*.js tests/*.js
|
|
188
|
-
|
|
189
|
-
The option is used as case insensitive regular expression.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
### Small print
|
|
194
|
-
|
|
195
|
-
Author: Gleb Bahmutov © 2014
|
|
196
|
-
|
|
197
|
-
* [@bahmutov](https://twitter.com/bahmutov)
|
|
198
|
-
* [glebbahmutov.com](http://glebbahmutov.com)
|
|
199
|
-
* [blog](http://bahmutov.calepin.co/)
|
|
200
|
-
|
|
201
|
-
License: [MIT](MIT-License.txt) - do anything with the code, but don't blame me if it does not work.
|
|
202
|
-
|
|
203
|
-
Spread the word: tweet, star on github, etc.
|
|
204
|
-
|
|
205
|
-
Support: if you find any problems with this module, email / tweet /
|
|
206
|
-
[open issue](https://github.com/bahmutov/gt/issues) on Github.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
[](https://bitdeli.com/free "Bitdeli Badge")
|
|
211
|
-
|
|
39
|
+
See the [full documentation](https://generaltranslation.com/docs/cli) for guides and API reference.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Settings } from '../types/index.js';
|
|
2
|
+
import { FileReference } from 'generaltranslation/types';
|
|
3
|
+
/**
|
|
4
|
+
* Collects local user edits by diffing the latest downloaded server translation version
|
|
5
|
+
* against the current local translation file, and submits the diffs upstream.
|
|
6
|
+
*
|
|
7
|
+
* Must run before enqueueing new translations so rules are available to the generator.
|
|
8
|
+
*/
|
|
9
|
+
export declare function collectAndSendUserEditDiffs(files: FileReference[], settings: Settings): Promise<void>;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getDownloadedVersions } from '../fs/config/downloadedVersions.js';
|
|
4
|
+
import { createFileMapping } from '../formats/files/fileMapping.js';
|
|
5
|
+
import { getGitUnifiedDiff } from '../utils/gitDiff.js';
|
|
6
|
+
import { gt } from '../utils/gt.js';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
9
|
+
import { hashStringSync } from '../utils/hash.js';
|
|
10
|
+
import { extractJson } from '../formats/json/extractJson.js';
|
|
11
|
+
const findLatestDownloadedVersion = (downloadedVersions, branchId, fileId, locale) => {
|
|
12
|
+
const versionsForFile = downloadedVersions.entries?.[branchId]?.[fileId] ?? undefined;
|
|
13
|
+
if (!versionsForFile)
|
|
14
|
+
return null;
|
|
15
|
+
let latest = null;
|
|
16
|
+
for (const [versionId, locales] of Object.entries(versionsForFile)) {
|
|
17
|
+
const entry = locales?.[locale];
|
|
18
|
+
if (!entry)
|
|
19
|
+
continue;
|
|
20
|
+
const updatedAt = entry.updatedAt
|
|
21
|
+
? Date.parse(entry.updatedAt)
|
|
22
|
+
: Number.NEGATIVE_INFINITY;
|
|
23
|
+
const latestUpdatedAt = latest?.entry.updatedAt
|
|
24
|
+
? Date.parse(latest.entry.updatedAt)
|
|
25
|
+
: Number.NEGATIVE_INFINITY;
|
|
26
|
+
if (!latest || updatedAt > latestUpdatedAt) {
|
|
27
|
+
latest = { versionId, entry };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return latest;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Collects local user edits by diffing the latest downloaded server translation version
|
|
34
|
+
* against the current local translation file, and submits the diffs upstream.
|
|
35
|
+
*
|
|
36
|
+
* Must run before enqueueing new translations so rules are available to the generator.
|
|
37
|
+
*/
|
|
38
|
+
export async function collectAndSendUserEditDiffs(files, settings) {
|
|
39
|
+
if (!settings.files)
|
|
40
|
+
return;
|
|
41
|
+
const { resolvedPaths, placeholderPaths, transformPaths } = settings.files;
|
|
42
|
+
const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, settings.locales, settings.defaultLocale);
|
|
43
|
+
const downloadedVersions = getDownloadedVersions(settings.configDirectory);
|
|
44
|
+
const tempDir = path.join(os.tmpdir(), randomUUID());
|
|
45
|
+
if (!fs.existsSync(tempDir))
|
|
46
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
47
|
+
const candidates = [];
|
|
48
|
+
for (const uploadedFile of files) {
|
|
49
|
+
for (const locale of settings.locales) {
|
|
50
|
+
const outputPath = fileMapping[locale]?.[uploadedFile.fileName] ?? null;
|
|
51
|
+
if (!outputPath)
|
|
52
|
+
continue;
|
|
53
|
+
if (!fs.existsSync(outputPath))
|
|
54
|
+
continue;
|
|
55
|
+
const latestDownloaded = findLatestDownloadedVersion(downloadedVersions, uploadedFile.branchId, uploadedFile.fileId, locale);
|
|
56
|
+
if (!latestDownloaded)
|
|
57
|
+
continue;
|
|
58
|
+
const downloadedVersion = latestDownloaded.entry;
|
|
59
|
+
// Skip if local file matches the last postprocessed content hash
|
|
60
|
+
if (downloadedVersion.postProcessHash) {
|
|
61
|
+
try {
|
|
62
|
+
const localContent = await fs.promises.readFile(outputPath, 'utf8');
|
|
63
|
+
const localHash = hashStringSync(localContent);
|
|
64
|
+
if (localHash === downloadedVersion.postProcessHash) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// If hash check fails, fall through to diff
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
candidates.push({
|
|
73
|
+
branchId: uploadedFile.branchId,
|
|
74
|
+
fileName: uploadedFile.fileName,
|
|
75
|
+
fileId: uploadedFile.fileId,
|
|
76
|
+
versionId: latestDownloaded.versionId,
|
|
77
|
+
locale: locale,
|
|
78
|
+
outputPath,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const collectedDiffs = [];
|
|
83
|
+
if (candidates.length > 0) {
|
|
84
|
+
const fileQueryData = candidates.map((c) => ({
|
|
85
|
+
versionId: c.versionId,
|
|
86
|
+
locale: c.locale,
|
|
87
|
+
fileId: c.fileId,
|
|
88
|
+
branchId: c.branchId,
|
|
89
|
+
}));
|
|
90
|
+
// Single batched check to obtain translation IDs
|
|
91
|
+
const checkResponse = await gt.queryFileData({
|
|
92
|
+
translatedFiles: fileQueryData,
|
|
93
|
+
});
|
|
94
|
+
const translatedFiles = checkResponse.translatedFiles?.filter((t) => t.completedAt) ?? [];
|
|
95
|
+
const serverContentByKey = new Map();
|
|
96
|
+
try {
|
|
97
|
+
const resp = await gt.downloadFileBatch(translatedFiles.map((file) => ({
|
|
98
|
+
branchId: file.branchId,
|
|
99
|
+
fileId: file.fileId,
|
|
100
|
+
locale: file.locale,
|
|
101
|
+
versionId: file.versionId,
|
|
102
|
+
})));
|
|
103
|
+
const files = resp?.files || [];
|
|
104
|
+
for (const f of files) {
|
|
105
|
+
serverContentByKey.set(`${f.branchId}:${f.fileId}:${f.versionId}:${f.locale}`, f.data);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// Ignore chunk failures; proceed with what we have
|
|
110
|
+
}
|
|
111
|
+
// Compute diffs using fetched server contents
|
|
112
|
+
for (const c of candidates) {
|
|
113
|
+
const key = `${c.branchId}:${c.fileId}:${c.versionId}:${c.locale}`;
|
|
114
|
+
const serverContent = serverContentByKey.get(key);
|
|
115
|
+
if (!serverContent)
|
|
116
|
+
continue;
|
|
117
|
+
try {
|
|
118
|
+
const safeName = Buffer.from(`${c.branchId}:${c.fileId}:${c.versionId}:${c.locale}`)
|
|
119
|
+
.toString('base64')
|
|
120
|
+
.replace(/=+$/g, '');
|
|
121
|
+
const tempServerFile = path.join(tempDir, `${safeName}.server`);
|
|
122
|
+
await fs.promises.writeFile(tempServerFile, serverContent, 'utf8');
|
|
123
|
+
const diff = await getGitUnifiedDiff(tempServerFile, c.outputPath);
|
|
124
|
+
try {
|
|
125
|
+
await fs.promises.unlink(tempServerFile);
|
|
126
|
+
}
|
|
127
|
+
catch { }
|
|
128
|
+
if (diff && diff.trim().length > 0) {
|
|
129
|
+
const rawLocalContent = await fs.promises.readFile(c.outputPath, 'utf8');
|
|
130
|
+
// For JSON files with jsonSchema config, extract to composite format
|
|
131
|
+
let localContent = rawLocalContent;
|
|
132
|
+
if (c.fileName.endsWith('.json') &&
|
|
133
|
+
settings.options?.jsonSchema &&
|
|
134
|
+
c.locale !== settings.defaultLocale) {
|
|
135
|
+
const extractedContent = extractJson(rawLocalContent, c.fileName, settings.options, c.locale, settings.defaultLocale);
|
|
136
|
+
if (extractedContent) {
|
|
137
|
+
localContent = extractedContent;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
collectedDiffs.push({
|
|
141
|
+
fileName: c.fileName,
|
|
142
|
+
locale: c.locale,
|
|
143
|
+
diff,
|
|
144
|
+
branchId: c.branchId,
|
|
145
|
+
versionId: c.versionId,
|
|
146
|
+
fileId: c.fileId,
|
|
147
|
+
localContent,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// Ignore failures for this file
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (collectedDiffs.length > 0) {
|
|
157
|
+
await gt.submitUserEditDiffs({ diffs: collectedDiffs });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Settings } from '../types/index.js';
|
|
2
|
+
import type { FileStatusTracker } from '../workflows/steps/PollJobsStep.js';
|
|
3
|
+
export type BatchedFiles = {
|
|
4
|
+
branchId: string;
|
|
5
|
+
fileId: string;
|
|
6
|
+
versionId: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
outputPath: string;
|
|
9
|
+
inputPath: string;
|
|
10
|
+
}[];
|
|
11
|
+
export type DownloadFileBatchResult = {
|
|
12
|
+
successful: BatchedFiles;
|
|
13
|
+
failed: BatchedFiles;
|
|
14
|
+
skipped: BatchedFiles;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Downloads multiple translation files in a single batch request
|
|
18
|
+
* @param files - Array of files to download with their output paths
|
|
19
|
+
* @param maxRetries - Maximum number of retry attempts
|
|
20
|
+
* @param retryDelay - Delay between retries in milliseconds
|
|
21
|
+
* @returns Object containing successful and failed file IDs
|
|
22
|
+
*/
|
|
23
|
+
export declare function downloadFileBatch(fileTracker: FileStatusTracker, files: BatchedFiles, options: Settings, forceDownload?: boolean): Promise<DownloadFileBatchResult>;
|