gtx-cli 2.6.31 → 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 +4 -1261
- package/README.md +12 -3
- package/dist/bin/bin-entry.js +2 -1
- package/dist/config/generateSettings.d.ts +1 -9
- package/dist/config/generateSettings.js +1 -214
- package/dist/config/resolveConfig.d.ts +1 -4
- package/dist/config/resolveConfig.js +1 -33
- package/dist/fs/config/setupConfig.d.ts +1 -17
- package/dist/fs/config/setupConfig.js +1 -50
- package/dist/fs/matchFiles.d.ts +1 -1
- package/dist/fs/matchFiles.js +1 -8
- package/dist/functions.d.ts +1 -7
- package/dist/functions.js +1 -6
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -27
- package/dist/main.js +2 -2
- package/dist/next/parse/handleInitGT.d.ts +1 -7
- package/dist/next/parse/handleInitGT.js +1 -157
- package/dist/next/parse/wrapContent.d.ts +1 -12
- package/dist/next/parse/wrapContent.js +1 -164
- package/dist/react/parse/wrapContent.d.ts +1 -12
- package/dist/react/parse/wrapContent.js +1 -162
- package/dist/types/index.d.ts +1 -243
- package/dist/types/index.js +1 -1
- package/dist/utils/installPackage.d.ts +1 -3
- package/dist/utils/installPackage.js +1 -77
- package/dist/utils/packageInfo.d.ts +1 -3
- package/dist/utils/packageInfo.js +1 -17
- package/dist/utils/packageJson.d.ts +1 -6
- package/dist/utils/packageJson.js +1 -68
- package/dist/utils/packageManager.d.ts +1 -28
- package/dist/utils/packageManager.js +1 -269
- package/package.json +11 -97
- package/dist/api/collectUserEditDiffs.d.ts +0 -9
- package/dist/api/collectUserEditDiffs.js +0 -159
- package/dist/api/downloadFileBatch.d.ts +0 -23
- package/dist/api/downloadFileBatch.js +0 -190
- package/dist/api/saveLocalEdits.d.ts +0 -6
- package/dist/api/saveLocalEdits.js +0 -38
- package/dist/cli/base.d.ts +0 -59
- package/dist/cli/base.js +0 -529
- package/dist/cli/commands/download.d.ts +0 -8
- package/dist/cli/commands/download.js +0 -51
- package/dist/cli/commands/enqueue.d.ts +0 -9
- package/dist/cli/commands/enqueue.js +0 -27
- package/dist/cli/commands/setupProject.d.ts +0 -7
- package/dist/cli/commands/setupProject.js +0 -37
- package/dist/cli/commands/stage.d.ts +0 -9
- package/dist/cli/commands/stage.js +0 -59
- package/dist/cli/commands/translate.d.ts +0 -7
- package/dist/cli/commands/translate.js +0 -70
- package/dist/cli/commands/upload.d.ts +0 -13
- package/dist/cli/commands/upload.js +0 -142
- package/dist/cli/commands/utils/validation.d.ts +0 -13
- package/dist/cli/commands/utils/validation.js +0 -38
- package/dist/cli/flags.d.ts +0 -15
- package/dist/cli/flags.js +0 -70
- package/dist/cli/inline.d.ts +0 -17
- package/dist/cli/inline.js +0 -135
- package/dist/cli/next.d.ts +0 -10
- package/dist/cli/next.js +0 -12
- package/dist/cli/node.d.ts +0 -10
- package/dist/cli/node.js +0 -9
- package/dist/cli/react.d.ts +0 -12
- package/dist/cli/react.js +0 -72
- package/dist/config/optionPresets.d.ts +0 -3
- package/dist/config/optionPresets.js +0 -65
- package/dist/config/utils.d.ts +0 -2
- package/dist/config/utils.js +0 -4
- package/dist/config/validateSettings.d.ts +0 -3
- package/dist/config/validateSettings.js +0 -32
- package/dist/console/colors.d.ts +0 -6
- package/dist/console/colors.js +0 -19
- package/dist/console/displayTranslateSummary.d.ts +0 -1
- package/dist/console/displayTranslateSummary.js +0 -42
- package/dist/console/formatting.d.ts +0 -1
- package/dist/console/formatting.js +0 -7
- package/dist/console/index.d.ts +0 -34
- package/dist/console/index.js +0 -46
- package/dist/console/logger.d.ts +0 -35
- package/dist/console/logger.js +0 -250
- package/dist/console/logging.d.ts +0 -52
- package/dist/console/logging.js +0 -175
- package/dist/formats/files/aggregateFiles.d.ts +0 -4
- package/dist/formats/files/aggregateFiles.js +0 -156
- package/dist/formats/files/collectFiles.d.ts +0 -6
- package/dist/formats/files/collectFiles.js +0 -49
- package/dist/formats/files/convertToFileTranslationData.d.ts +0 -15
- package/dist/formats/files/convertToFileTranslationData.js +0 -21
- package/dist/formats/files/fileMapping.d.ts +0 -11
- package/dist/formats/files/fileMapping.js +0 -115
- package/dist/formats/files/preprocess/mdx.d.ts +0 -6
- package/dist/formats/files/preprocess/mdx.js +0 -14
- package/dist/formats/files/preprocess/mintlify.d.ts +0 -5
- package/dist/formats/files/preprocess/mintlify.js +0 -15
- package/dist/formats/files/preprocessContent.d.ts +0 -8
- package/dist/formats/files/preprocessContent.js +0 -23
- package/dist/formats/files/save.d.ts +0 -5
- package/dist/formats/files/save.js +0 -17
- package/dist/formats/files/supportedFiles.d.ts +0 -11
- package/dist/formats/files/supportedFiles.js +0 -20
- package/dist/formats/json/extractJson.d.ts +0 -15
- package/dist/formats/json/extractJson.js +0 -101
- package/dist/formats/json/flattenJson.d.ts +0 -14
- package/dist/formats/json/flattenJson.js +0 -64
- package/dist/formats/json/mergeJson.d.ts +0 -13
- package/dist/formats/json/mergeJson.js +0 -367
- package/dist/formats/json/parseJson.d.ts +0 -2
- package/dist/formats/json/parseJson.js +0 -109
- package/dist/formats/json/utils.d.ts +0 -47
- package/dist/formats/json/utils.js +0 -150
- package/dist/formats/utils.d.ts +0 -2
- package/dist/formats/utils.js +0 -24
- package/dist/formats/yaml/mergeYaml.d.ts +0 -5
- package/dist/formats/yaml/mergeYaml.js +0 -61
- package/dist/formats/yaml/parseYaml.d.ts +0 -5
- package/dist/formats/yaml/parseYaml.js +0 -24
- package/dist/formats/yaml/utils.d.ts +0 -2
- package/dist/formats/yaml/utils.js +0 -23
- package/dist/fs/clearLocaleDirs.d.ts +0 -8
- package/dist/fs/clearLocaleDirs.js +0 -126
- package/dist/fs/config/downloadedVersions.d.ts +0 -21
- package/dist/fs/config/downloadedVersions.js +0 -50
- package/dist/fs/config/loadConfig.d.ts +0 -1
- package/dist/fs/config/loadConfig.js +0 -9
- package/dist/fs/config/parseFilesConfig.d.ts +0 -27
- package/dist/fs/config/parseFilesConfig.js +0 -150
- package/dist/fs/config/updateConfig.d.ts +0 -21
- package/dist/fs/config/updateConfig.js +0 -57
- package/dist/fs/config/updateVersions.d.ts +0 -11
- package/dist/fs/config/updateVersions.js +0 -30
- package/dist/fs/copyFile.d.ts +0 -7
- package/dist/fs/copyFile.js +0 -39
- package/dist/fs/createLoadTranslationsFile.d.ts +0 -1
- package/dist/fs/createLoadTranslationsFile.js +0 -49
- package/dist/fs/determineFramework.d.ts +0 -5
- package/dist/fs/determineFramework.js +0 -53
- package/dist/fs/findFilepath.d.ts +0 -36
- package/dist/fs/findFilepath.js +0 -90
- package/dist/fs/index.d.ts +0 -1
- package/dist/fs/index.js +0 -1
- package/dist/fs/loadJSON.d.ts +0 -6
- package/dist/fs/loadJSON.js +0 -17
- package/dist/fs/saveJSON.d.ts +0 -1
- package/dist/fs/saveJSON.js +0 -7
- package/dist/fs/utils.d.ts +0 -1
- package/dist/fs/utils.js +0 -16
- package/dist/generated/version.d.ts +0 -1
- package/dist/generated/version.js +0 -2
- package/dist/git/branches.d.ts +0 -7
- package/dist/git/branches.js +0 -88
- package/dist/hooks/postProcess.d.ts +0 -4
- package/dist/hooks/postProcess.js +0 -110
- package/dist/locadex/setupFlow.d.ts +0 -2
- package/dist/locadex/setupFlow.js +0 -9
- package/dist/next/config/parseNextConfig.d.ts +0 -10
- package/dist/next/config/parseNextConfig.js +0 -53
- package/dist/next/jsx/utils.d.ts +0 -7
- package/dist/next/jsx/utils.js +0 -42
- package/dist/react/config/createESBuildConfig.d.ts +0 -2
- package/dist/react/config/createESBuildConfig.js +0 -119
- package/dist/react/jsx/evaluateJsx.d.ts +0 -24
- package/dist/react/jsx/evaluateJsx.js +0 -123
- package/dist/react/jsx/utils/buildImportMap.d.ts +0 -9
- package/dist/react/jsx/utils/buildImportMap.js +0 -30
- package/dist/react/jsx/utils/constants.d.ts +0 -15
- package/dist/react/jsx/utils/constants.js +0 -49
- package/dist/react/jsx/utils/getCalleeNameFromExpression.d.ts +0 -9
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js +0 -32
- package/dist/react/jsx/utils/getPathsAndAliases.d.ts +0 -21
- package/dist/react/jsx/utils/getPathsAndAliases.js +0 -91
- package/dist/react/jsx/utils/isNumberLiteral.d.ts +0 -7
- package/dist/react/jsx/utils/isNumberLiteral.js +0 -13
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.d.ts +0 -9
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +0 -138
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.d.ts +0 -6
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +0 -197
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.d.ts +0 -13
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +0 -42
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.d.ts +0 -5
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +0 -69
- package/dist/react/jsx/utils/jsxParsing/parseJsx.d.ts +0 -33
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js +0 -918
- package/dist/react/jsx/utils/jsxParsing/parseTProps.d.ts +0 -8
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js +0 -65
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.d.ts +0 -2
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +0 -61
- package/dist/react/jsx/utils/jsxParsing/types.d.ts +0 -48
- package/dist/react/jsx/utils/jsxParsing/types.js +0 -34
- package/dist/react/jsx/utils/mapAttributeName.d.ts +0 -11
- package/dist/react/jsx/utils/mapAttributeName.js +0 -12
- package/dist/react/jsx/utils/parseAst.d.ts +0 -31
- package/dist/react/jsx/utils/parseAst.js +0 -278
- package/dist/react/jsx/utils/parseDeclareStatic.d.ts +0 -15
- package/dist/react/jsx/utils/parseDeclareStatic.js +0 -540
- package/dist/react/jsx/utils/parseString.d.ts +0 -25
- package/dist/react/jsx/utils/parseString.js +0 -540
- package/dist/react/jsx/utils/parseStringFunction.d.ts +0 -30
- package/dist/react/jsx/utils/parseStringFunction.js +0 -348
- package/dist/react/jsx/utils/resolveImportPath.d.ts +0 -11
- package/dist/react/jsx/utils/resolveImportPath.js +0 -111
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.d.ts +0 -29
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +0 -86
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.d.ts +0 -14
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +0 -24
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.d.ts +0 -19
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +0 -31
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.d.ts +0 -22
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleStaticTranslationCall.js +0 -51
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.d.ts +0 -18
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +0 -39
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.d.ts +0 -24
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +0 -68
- package/dist/react/jsx/utils/stringParsing/types.d.ts +0 -41
- package/dist/react/jsx/utils/stringParsing/types.js +0 -1
- package/dist/react/jsx/utils/types.d.ts +0 -14
- package/dist/react/jsx/utils/types.js +0 -1
- package/dist/react/jsx/utils/validateStringFunction.d.ts +0 -7
- package/dist/react/jsx/utils/validateStringFunction.js +0 -31
- package/dist/react/jsx/wrapJsx.d.ts +0 -51
- package/dist/react/jsx/wrapJsx.js +0 -387
- package/dist/react/parse/addVitePlugin/index.d.ts +0 -22
- package/dist/react/parse/addVitePlugin/index.js +0 -41
- package/dist/react/parse/addVitePlugin/installCompiler.d.ts +0 -8
- package/dist/react/parse/addVitePlugin/installCompiler.js +0 -22
- package/dist/react/parse/addVitePlugin/updateViteConfig.d.ts +0 -19
- package/dist/react/parse/addVitePlugin/updateViteConfig.js +0 -120
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.d.ts +0 -9
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +0 -34
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.d.ts +0 -11
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +0 -48
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.d.ts +0 -15
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +0 -113
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.d.ts +0 -12
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +0 -32
- package/dist/react/parse/createDictionaryUpdates.d.ts +0 -3
- package/dist/react/parse/createDictionaryUpdates.js +0 -187
- package/dist/react/parse/createInlineUpdates.d.ts +0 -13
- package/dist/react/parse/createInlineUpdates.js +0 -161
- package/dist/react/utils/flattenDictionary.d.ts +0 -20
- package/dist/react/utils/flattenDictionary.js +0 -75
- package/dist/react/utils/getEntryAndMetadata.d.ts +0 -5
- package/dist/react/utils/getEntryAndMetadata.js +0 -11
- package/dist/react/utils/getVariableName.d.ts +0 -25
- package/dist/react/utils/getVariableName.js +0 -37
- package/dist/setup/agentInstructions.d.ts +0 -24
- package/dist/setup/agentInstructions.js +0 -138
- package/dist/setup/detectFramework.d.ts +0 -31
- package/dist/setup/detectFramework.js +0 -106
- package/dist/setup/frameworkUtils.d.ts +0 -3
- package/dist/setup/frameworkUtils.js +0 -30
- package/dist/setup/instructions/base.md +0 -29
- package/dist/setup/instructions/gt-next.md +0 -107
- package/dist/setup/instructions/gt-react.md +0 -98
- package/dist/setup/userInput.d.ts +0 -4
- package/dist/setup/userInput.js +0 -32
- package/dist/setup/wizard.d.ts +0 -3
- package/dist/setup/wizard.js +0 -147
- package/dist/state/recentDownloads.d.ts +0 -12
- package/dist/state/recentDownloads.js +0 -18
- package/dist/state/translateWarnings.d.ts +0 -10
- package/dist/state/translateWarnings.js +0 -13
- package/dist/translation/parse.d.ts +0 -17
- package/dist/translation/parse.js +0 -77
- package/dist/translation/stage.d.ts +0 -3
- package/dist/translation/stage.js +0 -44
- package/dist/translation/validate.d.ts +0 -14
- package/dist/translation/validate.js +0 -100
- package/dist/types/branch.d.ts +0 -14
- package/dist/types/branch.js +0 -1
- package/dist/types/data/json.d.ts +0 -6
- package/dist/types/data/json.js +0 -1
- package/dist/types/data.d.ts +0 -37
- package/dist/types/data.js +0 -1
- package/dist/types/files.d.ts +0 -8
- package/dist/types/files.js +0 -1
- package/dist/types/libraries.d.ts +0 -31
- package/dist/types/libraries.js +0 -72
- package/dist/types/parsing.d.ts +0 -3
- package/dist/types/parsing.js +0 -1
- package/dist/utils/addExplicitAnchorIds.d.ts +0 -24
- package/dist/utils/addExplicitAnchorIds.js +0 -416
- package/dist/utils/constants.d.ts +0 -5
- package/dist/utils/constants.js +0 -6
- package/dist/utils/credentials.d.ts +0 -12
- package/dist/utils/credentials.js +0 -120
- package/dist/utils/flattenJsonFiles.d.ts +0 -2
- package/dist/utils/flattenJsonFiles.js +0 -36
- package/dist/utils/gitDiff.d.ts +0 -8
- package/dist/utils/gitDiff.js +0 -34
- package/dist/utils/gt.d.ts +0 -2
- package/dist/utils/gt.js +0 -2
- package/dist/utils/hash.d.ts +0 -6
- package/dist/utils/hash.js +0 -11
- package/dist/utils/headers.d.ts +0 -1
- package/dist/utils/headers.js +0 -14
- package/dist/utils/localizeRelativeAssets.d.ts +0 -8
- package/dist/utils/localizeRelativeAssets.js +0 -166
- package/dist/utils/localizeStaticImports.d.ts +0 -15
- package/dist/utils/localizeStaticImports.js +0 -397
- package/dist/utils/localizeStaticUrls.d.ts +0 -19
- package/dist/utils/localizeStaticUrls.js +0 -450
- package/dist/utils/mintlifyTitleFallback.d.ts +0 -6
- package/dist/utils/mintlifyTitleFallback.js +0 -80
- package/dist/utils/parse/needsCJS.d.ts +0 -20
- package/dist/utils/parse/needsCJS.js +0 -72
- package/dist/utils/persistPostprocessHashes.d.ts +0 -12
- package/dist/utils/persistPostprocessHashes.js +0 -39
- package/dist/utils/processAnchorIds.d.ts +0 -6
- package/dist/utils/processAnchorIds.js +0 -56
- package/dist/utils/processOpenApi.d.ts +0 -8
- package/dist/utils/processOpenApi.js +0 -651
- package/dist/utils/sanitizeFileContent.d.ts +0 -6
- package/dist/utils/sanitizeFileContent.js +0 -29
- package/dist/utils/sharedStaticAssets.d.ts +0 -9
- package/dist/utils/sharedStaticAssets.js +0 -384
- package/dist/utils/validateMdx.d.ts +0 -10
- package/dist/utils/validateMdx.js +0 -25
- package/dist/utils/wrapPlainUrls.d.ts +0 -8
- package/dist/utils/wrapPlainUrls.js +0 -72
- package/dist/workflows/download.d.ts +0 -32
- package/dist/workflows/download.js +0 -131
- package/dist/workflows/enqueue.d.ts +0 -17
- package/dist/workflows/enqueue.js +0 -59
- package/dist/workflows/setupProject.d.ts +0 -13
- package/dist/workflows/setupProject.js +0 -48
- package/dist/workflows/stage.d.ts +0 -18
- package/dist/workflows/stage.js +0 -59
- package/dist/workflows/steps/BranchStep.d.ts +0 -13
- package/dist/workflows/steps/BranchStep.js +0 -161
- package/dist/workflows/steps/DownloadStep.d.ts +0 -19
- package/dist/workflows/steps/DownloadStep.js +0 -131
- package/dist/workflows/steps/EnqueueStep.d.ts +0 -15
- package/dist/workflows/steps/EnqueueStep.js +0 -33
- package/dist/workflows/steps/PollJobsStep.d.ts +0 -31
- package/dist/workflows/steps/PollJobsStep.js +0 -288
- package/dist/workflows/steps/SetupStep.d.ts +0 -16
- package/dist/workflows/steps/SetupStep.js +0 -72
- package/dist/workflows/steps/UploadSourcesStep.d.ts +0 -27
- package/dist/workflows/steps/UploadSourcesStep.js +0 -131
- package/dist/workflows/steps/UploadTranslationsStep.d.ts +0 -22
- package/dist/workflows/steps/UploadTranslationsStep.js +0 -71
- package/dist/workflows/steps/UserEditDiffsStep.d.ts +0 -11
- package/dist/workflows/steps/UserEditDiffsStep.js +0 -30
- package/dist/workflows/steps/WorkflowStep.d.ts +0 -4
- package/dist/workflows/steps/WorkflowStep.js +0 -2
- package/dist/workflows/upload.d.ts +0 -15
- package/dist/workflows/upload.js +0 -47
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
3
|
-
import { logger } from '../../console/logger.js';
|
|
4
|
-
import { TEMPLATE_FILE_NAME } from '../../utils/constants.js';
|
|
5
|
-
export class PollTranslationJobsStep extends WorkflowStep {
|
|
6
|
-
gt;
|
|
7
|
-
spinner = null;
|
|
8
|
-
previousProgress = 0;
|
|
9
|
-
constructor(gt) {
|
|
10
|
-
super();
|
|
11
|
-
this.gt = gt;
|
|
12
|
-
}
|
|
13
|
-
async run({ fileTracker, fileQueryData, jobData, timeoutDuration, forceRetranslation, }) {
|
|
14
|
-
const startTime = Date.now();
|
|
15
|
-
this.spinner = logger.createProgressBar(fileQueryData.length);
|
|
16
|
-
const spinnerMessage = forceRetranslation
|
|
17
|
-
? 'Waiting for retranslation...'
|
|
18
|
-
: 'Waiting for translation...';
|
|
19
|
-
this.spinner.start(spinnerMessage);
|
|
20
|
-
// Build a map of branchId:fileId:versionId:locale -> FileProperties
|
|
21
|
-
const filePropertiesMap = new Map();
|
|
22
|
-
fileQueryData.forEach((item) => {
|
|
23
|
-
filePropertiesMap.set(`${item.branchId}:${item.fileId}:${item.versionId}:${item.locale}`, item);
|
|
24
|
-
});
|
|
25
|
-
// Initial query to check which files already have translations
|
|
26
|
-
const initialFileData = await this.gt.queryFileData({
|
|
27
|
-
translatedFiles: fileQueryData.map((item) => ({
|
|
28
|
-
fileId: item.fileId,
|
|
29
|
-
versionId: item.versionId,
|
|
30
|
-
branchId: item.branchId,
|
|
31
|
-
locale: item.locale,
|
|
32
|
-
})),
|
|
33
|
-
});
|
|
34
|
-
const existingTranslations = initialFileData.translatedFiles || [];
|
|
35
|
-
// Mark all existing translations as completed
|
|
36
|
-
existingTranslations.forEach((translation) => {
|
|
37
|
-
if (!translation.completedAt) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const fileKey = `${translation.branchId}:${translation.fileId}:${translation.versionId}:${translation.locale}`;
|
|
41
|
-
const fileProperties = filePropertiesMap.get(fileKey);
|
|
42
|
-
if (fileProperties) {
|
|
43
|
-
fileTracker.completed.set(fileKey, fileProperties);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
// Build a map of jobs for quick lookup:
|
|
47
|
-
// branchId:fileId:versionId:locale -> job
|
|
48
|
-
const jobMap = new Map();
|
|
49
|
-
Object.entries(jobData.jobData).forEach(([jobId, job]) => {
|
|
50
|
-
const jobLocale = this.gt.resolveAliasLocale(job.targetLocale);
|
|
51
|
-
const key = `${job.branchId}:${job.fileId}:${job.versionId}:${jobLocale}`;
|
|
52
|
-
jobMap.set(key, { ...job, jobId, targetLocale: jobLocale });
|
|
53
|
-
});
|
|
54
|
-
// Build a map of jobs for quick lookup:
|
|
55
|
-
// jobId -> file data for the job
|
|
56
|
-
const jobFileMap = new Map();
|
|
57
|
-
Object.entries(jobData.jobData).forEach(([jobId, job]) => {
|
|
58
|
-
const jobLocale = this.gt.resolveAliasLocale(job.targetLocale);
|
|
59
|
-
jobFileMap.set(jobId, {
|
|
60
|
-
branchId: job.branchId,
|
|
61
|
-
fileId: job.fileId,
|
|
62
|
-
versionId: job.versionId,
|
|
63
|
-
locale: jobLocale,
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
// Categorize each file query item
|
|
67
|
-
for (const item of fileQueryData) {
|
|
68
|
-
const fileKey = `${item.branchId}:${item.fileId}:${item.versionId}:${item.locale}`;
|
|
69
|
-
// Check if translation already exists (completedAt is truthy)
|
|
70
|
-
const existingTranslation = fileTracker.completed.get(fileKey);
|
|
71
|
-
if (existingTranslation) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
// Check if there's a job for this file
|
|
75
|
-
const jobKey = `${item.branchId}:${item.fileId}:${item.versionId}:${item.locale}`;
|
|
76
|
-
const job = jobMap.get(jobKey);
|
|
77
|
-
if (job) {
|
|
78
|
-
// Job exists - mark as in progress initially
|
|
79
|
-
fileTracker.inProgress.set(fileKey, item);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
// No job and no existing translation - mark as skipped
|
|
83
|
-
fileTracker.skipped.set(fileKey, item);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Update spinner with initial status
|
|
87
|
-
this.updateSpinner(fileTracker, fileQueryData);
|
|
88
|
-
// If force retranslation, don't skip the initial check
|
|
89
|
-
if (!forceRetranslation) {
|
|
90
|
-
// Check if all jobs are already complete
|
|
91
|
-
if (fileTracker.inProgress.size === 0) {
|
|
92
|
-
this.spinner.stop(chalk.green('All translations ready'));
|
|
93
|
-
return { success: true, fileTracker };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// Calculate time until next 5-second interval since startTime
|
|
97
|
-
const msUntilNextInterval = Math.max(0, 5000 - ((Date.now() - startTime) % 5000));
|
|
98
|
-
return new Promise((resolve) => {
|
|
99
|
-
let intervalCheck;
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
intervalCheck = setInterval(async () => {
|
|
102
|
-
try {
|
|
103
|
-
// Query job status
|
|
104
|
-
const jobIds = Array.from(jobFileMap.keys());
|
|
105
|
-
const jobStatusResponse = await this.gt.checkJobStatus(jobIds);
|
|
106
|
-
// Update status based on job completion
|
|
107
|
-
for (const job of jobStatusResponse) {
|
|
108
|
-
const jobFileProperties = jobFileMap.get(job.jobId);
|
|
109
|
-
if (jobFileProperties) {
|
|
110
|
-
const fileKey = `${jobFileProperties.branchId}:${jobFileProperties.fileId}:${jobFileProperties.versionId}:${jobFileProperties.locale}`;
|
|
111
|
-
const fileProperties = filePropertiesMap.get(fileKey);
|
|
112
|
-
if (!fileProperties) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
if (job.status === 'completed') {
|
|
116
|
-
fileTracker.completed.set(fileKey, fileProperties);
|
|
117
|
-
fileTracker.inProgress.delete(fileKey);
|
|
118
|
-
jobFileMap.delete(job.jobId);
|
|
119
|
-
}
|
|
120
|
-
else if (job.status === 'failed') {
|
|
121
|
-
fileTracker.failed.set(fileKey, fileProperties);
|
|
122
|
-
fileTracker.inProgress.delete(fileKey);
|
|
123
|
-
jobFileMap.delete(job.jobId);
|
|
124
|
-
}
|
|
125
|
-
else if (job.status === 'unknown') {
|
|
126
|
-
fileTracker.skipped.set(fileKey, fileProperties);
|
|
127
|
-
fileTracker.inProgress.delete(fileKey);
|
|
128
|
-
jobFileMap.delete(job.jobId);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
// Update spinner
|
|
133
|
-
this.updateSpinner(fileTracker, fileQueryData);
|
|
134
|
-
const elapsed = Date.now() - startTime;
|
|
135
|
-
const allJobsProcessed = fileTracker.inProgress.size === 0;
|
|
136
|
-
if (allJobsProcessed || elapsed >= timeoutDuration * 1000) {
|
|
137
|
-
clearInterval(intervalCheck);
|
|
138
|
-
if (fileTracker.inProgress.size === 0) {
|
|
139
|
-
this.spinner.stop(chalk.green('Translation jobs finished'));
|
|
140
|
-
resolve({ success: true, fileTracker });
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
this.spinner.stop(chalk.red('Timed out waiting for translation jobs'));
|
|
144
|
-
resolve({ success: false, fileTracker });
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
logger.error(chalk.red('Error checking job status: ') + error);
|
|
150
|
-
}
|
|
151
|
-
}, 5000);
|
|
152
|
-
}, msUntilNextInterval);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
updateSpinner(fileTracker, fileQueryData) {
|
|
156
|
-
if (!this.spinner)
|
|
157
|
-
return;
|
|
158
|
-
const statusText = this.generateStatusSuffixText(fileTracker, fileQueryData);
|
|
159
|
-
const currentProgress = fileTracker.completed.size +
|
|
160
|
-
fileTracker.failed.size +
|
|
161
|
-
fileTracker.skipped.size;
|
|
162
|
-
const progressDelta = currentProgress - this.previousProgress;
|
|
163
|
-
this.spinner.advance(progressDelta, statusText);
|
|
164
|
-
this.previousProgress = currentProgress;
|
|
165
|
-
}
|
|
166
|
-
generateStatusSuffixText(fileTracker, fileQueryData) {
|
|
167
|
-
// Simple progress indicator
|
|
168
|
-
const progressText = `${chalk.green(`[${fileTracker.completed.size +
|
|
169
|
-
fileTracker.failed.size +
|
|
170
|
-
fileTracker.skipped.size}/${fileQueryData.length}]`)} translations completed`;
|
|
171
|
-
// Get terminal height to adapt our output
|
|
172
|
-
const terminalHeight = process.stdout.rows || 24;
|
|
173
|
-
// If terminal is very small, just show the basic progress
|
|
174
|
-
if (terminalHeight < 6) {
|
|
175
|
-
return progressText;
|
|
176
|
-
}
|
|
177
|
-
const newSuffixText = [progressText];
|
|
178
|
-
// Organize data by filename : locale
|
|
179
|
-
const fileStatus = new Map();
|
|
180
|
-
// Initialize with all files and locales from fileQueryData
|
|
181
|
-
for (const item of fileQueryData) {
|
|
182
|
-
if (!fileStatus.has(item.fileName)) {
|
|
183
|
-
fileStatus.set(item.fileName, {
|
|
184
|
-
completed: new Set(),
|
|
185
|
-
pending: new Set([item.locale]),
|
|
186
|
-
failed: new Set(),
|
|
187
|
-
skipped: new Set(),
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
fileStatus.get(item.fileName)?.pending.add(item.locale);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
// Mark which ones are completed, failed, or skipped
|
|
195
|
-
for (const [_, fileProperties] of fileTracker.completed) {
|
|
196
|
-
const { fileName, locale } = fileProperties;
|
|
197
|
-
const status = fileStatus.get(fileName);
|
|
198
|
-
if (status) {
|
|
199
|
-
status.pending.delete(locale);
|
|
200
|
-
status.completed.add(locale);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
for (const [_, fileProperties] of fileTracker.failed) {
|
|
204
|
-
const { fileName, locale } = fileProperties;
|
|
205
|
-
const status = fileStatus.get(fileName);
|
|
206
|
-
if (status) {
|
|
207
|
-
status.pending.delete(locale);
|
|
208
|
-
status.failed.add(locale);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
for (const [_, fileProperties] of fileTracker.skipped) {
|
|
212
|
-
const { fileName, locale } = fileProperties;
|
|
213
|
-
const status = fileStatus.get(fileName);
|
|
214
|
-
if (status) {
|
|
215
|
-
status.pending.delete(locale);
|
|
216
|
-
status.skipped.add(locale);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
// Calculate how many files we can show based on terminal height
|
|
220
|
-
const filesArray = Array.from(fileStatus.entries());
|
|
221
|
-
const maxFilesToShow = Math.min(filesArray.length, terminalHeight - 3 // Header + progress + buffer
|
|
222
|
-
);
|
|
223
|
-
// Display each file with its status on a single line
|
|
224
|
-
for (let i = 0; i < maxFilesToShow; i++) {
|
|
225
|
-
const [fileName, status] = filesArray[i];
|
|
226
|
-
// Create condensed locale status
|
|
227
|
-
const localeStatuses = [];
|
|
228
|
-
// Add completed locales (green)
|
|
229
|
-
if (status.completed.size > 0) {
|
|
230
|
-
localeStatuses.push(...Array.from(status.completed).map((locale) => ({
|
|
231
|
-
locale,
|
|
232
|
-
status: 'completed',
|
|
233
|
-
})));
|
|
234
|
-
}
|
|
235
|
-
// Add skipped locales (green)
|
|
236
|
-
if (status.skipped.size > 0) {
|
|
237
|
-
localeStatuses.push(...Array.from(status.skipped).map((locale) => ({
|
|
238
|
-
locale,
|
|
239
|
-
status: 'skipped',
|
|
240
|
-
})));
|
|
241
|
-
}
|
|
242
|
-
// Add failed locales (red)
|
|
243
|
-
if (status.failed.size > 0) {
|
|
244
|
-
localeStatuses.push(...Array.from(status.failed).map((locale) => ({
|
|
245
|
-
locale,
|
|
246
|
-
status: 'failed',
|
|
247
|
-
})));
|
|
248
|
-
}
|
|
249
|
-
// Add pending locales (yellow)
|
|
250
|
-
if (status.pending.size > 0) {
|
|
251
|
-
localeStatuses.push(...Array.from(status.pending).map((locale) => ({
|
|
252
|
-
locale,
|
|
253
|
-
status: 'pending',
|
|
254
|
-
})));
|
|
255
|
-
}
|
|
256
|
-
// Sort localeStatuses by locale
|
|
257
|
-
localeStatuses.sort((a, b) => a.locale.localeCompare(b.locale));
|
|
258
|
-
// Add colors
|
|
259
|
-
const localeString = localeStatuses
|
|
260
|
-
.map((locale) => {
|
|
261
|
-
if (locale.status === 'completed') {
|
|
262
|
-
return chalk.green(locale.locale);
|
|
263
|
-
}
|
|
264
|
-
else if (locale.status === 'skipped') {
|
|
265
|
-
return chalk.gray(locale.locale);
|
|
266
|
-
}
|
|
267
|
-
else if (locale.status === 'failed') {
|
|
268
|
-
return chalk.red(locale.locale);
|
|
269
|
-
}
|
|
270
|
-
else if (locale.status === 'pending') {
|
|
271
|
-
return chalk.yellow(locale.locale);
|
|
272
|
-
}
|
|
273
|
-
})
|
|
274
|
-
.join(', ');
|
|
275
|
-
// Format the line
|
|
276
|
-
const prettyFileName = fileName === TEMPLATE_FILE_NAME ? '<React Elements>' : fileName;
|
|
277
|
-
newSuffixText.push(`${chalk.bold(prettyFileName)} [${localeString}]`);
|
|
278
|
-
}
|
|
279
|
-
// If we couldn't show all files, add an indicator
|
|
280
|
-
if (filesArray.length > maxFilesToShow) {
|
|
281
|
-
newSuffixText.push(`... and ${filesArray.length - maxFilesToShow} more files`);
|
|
282
|
-
}
|
|
283
|
-
return newSuffixText.join('\n');
|
|
284
|
-
}
|
|
285
|
-
async wait() {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FileReference } from 'generaltranslation/types';
|
|
2
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
3
|
-
import { GT } from 'generaltranslation';
|
|
4
|
-
import { Settings } from '../../types/index.js';
|
|
5
|
-
export declare class SetupStep extends WorkflowStep<FileReference[], FileReference[]> {
|
|
6
|
-
private gt;
|
|
7
|
-
private settings;
|
|
8
|
-
private timeoutMs;
|
|
9
|
-
private spinner;
|
|
10
|
-
private setupJobId;
|
|
11
|
-
private files;
|
|
12
|
-
private completed;
|
|
13
|
-
constructor(gt: GT, settings: Settings, timeoutMs: number);
|
|
14
|
-
run(files: FileReference[], force?: boolean): Promise<FileReference[]>;
|
|
15
|
-
wait(): Promise<void>;
|
|
16
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
2
|
-
import { logger } from '../../console/logger.js';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
export class SetupStep extends WorkflowStep {
|
|
5
|
-
gt;
|
|
6
|
-
settings;
|
|
7
|
-
timeoutMs;
|
|
8
|
-
spinner = logger.createSpinner('dots');
|
|
9
|
-
setupJobId = null;
|
|
10
|
-
files = null;
|
|
11
|
-
completed = false;
|
|
12
|
-
constructor(gt, settings, timeoutMs) {
|
|
13
|
-
super();
|
|
14
|
-
this.gt = gt;
|
|
15
|
-
this.settings = settings;
|
|
16
|
-
this.timeoutMs = timeoutMs;
|
|
17
|
-
}
|
|
18
|
-
async run(files, force = false) {
|
|
19
|
-
this.files = files;
|
|
20
|
-
this.spinner.start('Setting up project...');
|
|
21
|
-
if (files.length === 0) {
|
|
22
|
-
this.completed = true;
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
const result = await this.gt.setupProject(files, {
|
|
26
|
-
locales: this.settings.locales,
|
|
27
|
-
force,
|
|
28
|
-
});
|
|
29
|
-
if (result.status === 'completed') {
|
|
30
|
-
this.completed = true;
|
|
31
|
-
return files;
|
|
32
|
-
}
|
|
33
|
-
if (result.status === 'queued') {
|
|
34
|
-
this.setupJobId = result.setupJobId;
|
|
35
|
-
return files;
|
|
36
|
-
}
|
|
37
|
-
// Unknown status
|
|
38
|
-
this.completed = true;
|
|
39
|
-
return files;
|
|
40
|
-
}
|
|
41
|
-
async wait() {
|
|
42
|
-
if (this.completed) {
|
|
43
|
-
this.spinner.stop(chalk.green('Setup successfully completed'));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (!this.setupJobId) {
|
|
47
|
-
this.spinner.stop(chalk.yellow('Setup status unknown — proceeding without setup'));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
// Poll for completion
|
|
51
|
-
const start = Date.now();
|
|
52
|
-
const pollInterval = 5000; // 5 seconds
|
|
53
|
-
while (Date.now() - start < this.timeoutMs) {
|
|
54
|
-
const status = await this.gt.checkJobStatus([this.setupJobId]);
|
|
55
|
-
if (!status[0]) {
|
|
56
|
-
this.spinner.stop(chalk.yellow('Setup status unknown — proceeding without setup'));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (status[0].status === 'completed') {
|
|
60
|
-
this.spinner.stop(chalk.green('Setup successfully completed'));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (status[0].status === 'failed') {
|
|
64
|
-
this.spinner.stop(chalk.yellow(`Setup failed: ${status[0].error?.message || 'Unknown error'} — proceeding without setup`));
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
await new Promise((r) => setTimeout(r, pollInterval));
|
|
68
|
-
}
|
|
69
|
-
// Timeout
|
|
70
|
-
this.spinner.stop(chalk.yellow('Setup timed out — proceeding without setup'));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { FileToUpload } from 'generaltranslation/types';
|
|
2
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
3
|
-
import { GT } from 'generaltranslation';
|
|
4
|
-
import { Settings } from '../../types/index.js';
|
|
5
|
-
import { BranchData } from '../../types/branch.js';
|
|
6
|
-
import type { FileReference } from 'generaltranslation/types';
|
|
7
|
-
export declare class UploadSourcesStep extends WorkflowStep<{
|
|
8
|
-
files: FileToUpload[];
|
|
9
|
-
branchData: BranchData;
|
|
10
|
-
}, FileReference[]> {
|
|
11
|
-
private gt;
|
|
12
|
-
private settings;
|
|
13
|
-
private spinner;
|
|
14
|
-
private result;
|
|
15
|
-
constructor(gt: GT, settings: Settings);
|
|
16
|
-
/**
|
|
17
|
-
* Detects file moves by comparing local files against orphaned files.
|
|
18
|
-
* A move is detected when a local file has the same versionId (content hash)
|
|
19
|
-
* as an orphaned file but a different fileId (path hash).
|
|
20
|
-
*/
|
|
21
|
-
private detectMoves;
|
|
22
|
-
run({ files, branchData, }: {
|
|
23
|
-
files: FileToUpload[];
|
|
24
|
-
branchData: BranchData;
|
|
25
|
-
}): Promise<FileReference[]>;
|
|
26
|
-
wait(): Promise<void>;
|
|
27
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
2
|
-
import { logger } from '../../console/logger.js';
|
|
3
|
-
import { recordWarning } from '../../state/translateWarnings.js';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
export class UploadSourcesStep extends WorkflowStep {
|
|
6
|
-
gt;
|
|
7
|
-
settings;
|
|
8
|
-
spinner = logger.createSpinner('dots');
|
|
9
|
-
result = null;
|
|
10
|
-
constructor(gt, settings) {
|
|
11
|
-
super();
|
|
12
|
-
this.gt = gt;
|
|
13
|
-
this.settings = settings;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Detects file moves by comparing local files against orphaned files.
|
|
17
|
-
* A move is detected when a local file has the same versionId (content hash)
|
|
18
|
-
* as an orphaned file but a different fileId (path hash).
|
|
19
|
-
*/
|
|
20
|
-
detectMoves(localFiles, orphanedFiles) {
|
|
21
|
-
const moves = [];
|
|
22
|
-
// Build a map of versionId -> orphaned file
|
|
23
|
-
const orphansByVersionId = new Map();
|
|
24
|
-
for (const orphan of orphanedFiles) {
|
|
25
|
-
orphansByVersionId.set(orphan.versionId, orphan);
|
|
26
|
-
}
|
|
27
|
-
// Check each local file against orphaned files
|
|
28
|
-
for (const local of localFiles) {
|
|
29
|
-
const orphan = orphansByVersionId.get(local.versionId);
|
|
30
|
-
if (orphan && orphan.fileId !== local.fileId) {
|
|
31
|
-
// Same content, different path = move detected
|
|
32
|
-
moves.push({
|
|
33
|
-
oldFileId: orphan.fileId,
|
|
34
|
-
newFileId: local.fileId,
|
|
35
|
-
newFileName: local.fileName,
|
|
36
|
-
});
|
|
37
|
-
// Remove from map to avoid matching same orphan twice
|
|
38
|
-
orphansByVersionId.delete(local.versionId);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return moves;
|
|
42
|
-
}
|
|
43
|
-
async run({ files, branchData, }) {
|
|
44
|
-
if (files.length === 0) {
|
|
45
|
-
logger.info('No files to upload found... skipping upload step');
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
const currentBranchId = branchData.currentBranch.id;
|
|
49
|
-
this.spinner.start(`Syncing ${files.length} file${files.length !== 1 ? 's' : ''} with General Translation API...`);
|
|
50
|
-
// Query file data and orphaned files in parallel
|
|
51
|
-
const [fileData, orphanedFilesResult] = await Promise.all([
|
|
52
|
-
this.gt.queryFileData({
|
|
53
|
-
sourceFiles: files.map((f) => ({
|
|
54
|
-
fileId: f.fileId,
|
|
55
|
-
versionId: f.versionId,
|
|
56
|
-
branchId: f.branchId ?? currentBranchId,
|
|
57
|
-
})),
|
|
58
|
-
}),
|
|
59
|
-
this.gt.getOrphanedFiles(currentBranchId, files.map((f) => f.fileId)),
|
|
60
|
-
]);
|
|
61
|
-
// Detect file moves
|
|
62
|
-
const moves = this.detectMoves(files, orphanedFilesResult.orphanedFiles);
|
|
63
|
-
// Track successfully moved files
|
|
64
|
-
let successfullyMovedFileIds = new Set();
|
|
65
|
-
// Process moves if any were detected
|
|
66
|
-
if (moves.length > 0) {
|
|
67
|
-
this.spinner.message(`Detected ${moves.length} moved file${moves.length !== 1 ? 's' : ''}, preserving translations...`);
|
|
68
|
-
const moveResult = await this.gt.processFileMoves(moves, {
|
|
69
|
-
branchId: currentBranchId,
|
|
70
|
-
});
|
|
71
|
-
// Only track files where the move actually succeeded
|
|
72
|
-
successfullyMovedFileIds = new Set(moveResult.results.filter((r) => r.success).map((r) => r.newFileId));
|
|
73
|
-
const failed = moveResult.summary.failed;
|
|
74
|
-
if (failed > 0) {
|
|
75
|
-
logger.warn(`Failed to migrate ${failed} moved file${failed !== 1 ? 's' : ''}`);
|
|
76
|
-
for (const r of moveResult.results) {
|
|
77
|
-
if (!r.success) {
|
|
78
|
-
const move = moves.find((m) => m.newFileId === r.newFileId);
|
|
79
|
-
recordWarning('failed_move', move?.newFileName ?? r.newFileId, r.error ?? 'Unknown error');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Build a map of branch:fileId:versionId to fileData
|
|
85
|
-
const fileDataMap = new Map();
|
|
86
|
-
fileData.sourceFiles?.forEach((f) => {
|
|
87
|
-
fileDataMap.set(`${f.branchId}:${f.fileId}:${f.versionId}`, f);
|
|
88
|
-
});
|
|
89
|
-
// Build a list of files that need to be uploaded
|
|
90
|
-
const filesToUpload = [];
|
|
91
|
-
const filesToSkipUpload = [];
|
|
92
|
-
files.forEach((f) => {
|
|
93
|
-
const key = `${f.branchId ?? currentBranchId}:${f.fileId}:${f.versionId}`;
|
|
94
|
-
if (fileDataMap.has(key) || successfullyMovedFileIds.has(f.fileId)) {
|
|
95
|
-
filesToSkipUpload.push(f);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
filesToUpload.push(f);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
const response = await this.gt.uploadSourceFiles(filesToUpload.map((f) => ({
|
|
102
|
-
source: {
|
|
103
|
-
...f,
|
|
104
|
-
branchId: f.branchId ?? currentBranchId,
|
|
105
|
-
locale: this.settings.defaultLocale,
|
|
106
|
-
incomingBranchId: branchData.incomingBranch?.id,
|
|
107
|
-
checkedOutBranchId: branchData.checkedOutBranch?.id,
|
|
108
|
-
},
|
|
109
|
-
})), {
|
|
110
|
-
sourceLocale: this.settings.defaultLocale,
|
|
111
|
-
modelProvider: this.settings.modelProvider,
|
|
112
|
-
});
|
|
113
|
-
this.result = response.uploadedFiles;
|
|
114
|
-
// Merge files that were already uploaded into the result
|
|
115
|
-
this.result.push(...filesToSkipUpload.map((f) => ({
|
|
116
|
-
fileId: f.fileId,
|
|
117
|
-
versionId: f.versionId,
|
|
118
|
-
branchId: f.branchId ?? currentBranchId,
|
|
119
|
-
fileName: f.fileName,
|
|
120
|
-
fileFormat: f.fileFormat,
|
|
121
|
-
dataFormat: f.dataFormat,
|
|
122
|
-
locale: f.locale,
|
|
123
|
-
})));
|
|
124
|
-
const moveMsg = moves.length > 0 ? ` (${moves.length} moved)` : '';
|
|
125
|
-
this.spinner.stop(chalk.green(`Files uploaded successfully${moveMsg}`));
|
|
126
|
-
return this.result;
|
|
127
|
-
}
|
|
128
|
-
async wait() {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
2
|
-
import { GT } from 'generaltranslation';
|
|
3
|
-
import { Settings } from '../../types/index.js';
|
|
4
|
-
import { BranchData } from '../../types/branch.js';
|
|
5
|
-
import type { FileReference, FileToUpload } from 'generaltranslation/types';
|
|
6
|
-
type UploadTranslationsInput = {
|
|
7
|
-
files: {
|
|
8
|
-
source: FileToUpload;
|
|
9
|
-
translations: FileToUpload[];
|
|
10
|
-
}[];
|
|
11
|
-
branchData: BranchData;
|
|
12
|
-
};
|
|
13
|
-
export declare class UploadTranslationsStep extends WorkflowStep<UploadTranslationsInput, FileReference[]> {
|
|
14
|
-
private gt;
|
|
15
|
-
private settings;
|
|
16
|
-
private spinner;
|
|
17
|
-
private result;
|
|
18
|
-
constructor(gt: GT, settings: Settings);
|
|
19
|
-
run({ files, branchData, }: UploadTranslationsInput): Promise<FileReference[]>;
|
|
20
|
-
wait(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
2
|
-
import { logger } from '../../console/logger.js';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
export class UploadTranslationsStep extends WorkflowStep {
|
|
5
|
-
gt;
|
|
6
|
-
settings;
|
|
7
|
-
spinner = logger.createSpinner('dots');
|
|
8
|
-
result = [];
|
|
9
|
-
constructor(gt, settings) {
|
|
10
|
-
super();
|
|
11
|
-
this.gt = gt;
|
|
12
|
-
this.settings = settings;
|
|
13
|
-
}
|
|
14
|
-
async run({ files, branchData, }) {
|
|
15
|
-
// Filter to only files that have translations
|
|
16
|
-
const filesWithTranslations = files.filter((f) => f.translations.length > 0);
|
|
17
|
-
if (filesWithTranslations.length === 0) {
|
|
18
|
-
logger.info('No translation files to upload... skipping upload translations step');
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
const totalTranslations = filesWithTranslations.reduce((acc, f) => acc + f.translations.length, 0);
|
|
22
|
-
this.spinner.start(`Syncing ${totalTranslations} translation file${totalTranslations !== 1 ? 's' : ''} with General Translation API...`);
|
|
23
|
-
// Build the query for existing translation files
|
|
24
|
-
const translatedFilesQuery = filesWithTranslations.flatMap((f) => f.translations.map((t) => ({
|
|
25
|
-
fileId: t.fileId,
|
|
26
|
-
versionId: t.versionId,
|
|
27
|
-
branchId: t.branchId ?? branchData.currentBranch.id,
|
|
28
|
-
locale: t.locale,
|
|
29
|
-
})));
|
|
30
|
-
// Query for existing translation files
|
|
31
|
-
const fileData = await this.gt.queryFileData({
|
|
32
|
-
translatedFiles: translatedFilesQuery,
|
|
33
|
-
});
|
|
34
|
-
// Build a map of existing translations: branchId:fileId:versionId:locale
|
|
35
|
-
const existingTranslationsMap = new Set();
|
|
36
|
-
fileData.translatedFiles?.forEach((f) => {
|
|
37
|
-
existingTranslationsMap.add(`${f.branchId}:${f.fileId}:${f.versionId}:${f.locale}`);
|
|
38
|
-
});
|
|
39
|
-
// Filter out translations that already exist
|
|
40
|
-
const filesToUpload = filesWithTranslations
|
|
41
|
-
.map((f) => {
|
|
42
|
-
const newTranslations = f.translations.filter((t) => {
|
|
43
|
-
const branchId = t.branchId ?? branchData.currentBranch.id;
|
|
44
|
-
const key = `${branchId}:${t.fileId}:${t.versionId}:${t.locale}`;
|
|
45
|
-
return !existingTranslationsMap.has(key);
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
source: f.source,
|
|
49
|
-
translations: newTranslations,
|
|
50
|
-
};
|
|
51
|
-
})
|
|
52
|
-
.filter((f) => f.translations.length > 0);
|
|
53
|
-
const skippedCount = totalTranslations -
|
|
54
|
-
filesToUpload.reduce((acc, f) => acc + f.translations.length, 0);
|
|
55
|
-
if (filesToUpload.length === 0) {
|
|
56
|
-
this.spinner.stop(chalk.green(`All ${totalTranslations} translation files already uploaded`));
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
const uploadCount = filesToUpload.reduce((acc, f) => acc + f.translations.length, 0);
|
|
60
|
-
const response = await this.gt.uploadTranslations(filesToUpload, {
|
|
61
|
-
sourceLocale: this.settings.defaultLocale,
|
|
62
|
-
modelProvider: this.settings.modelProvider,
|
|
63
|
-
});
|
|
64
|
-
this.result = response.uploadedFiles;
|
|
65
|
-
this.spinner.stop(chalk.green(`Translation files synced successfully! Uploaded: (${uploadCount}), Skipped: (${skippedCount})`));
|
|
66
|
-
return this.result;
|
|
67
|
-
}
|
|
68
|
-
async wait() {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { FileReference } from 'generaltranslation/types';
|
|
2
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
3
|
-
import { Settings } from '../../types/index.js';
|
|
4
|
-
export declare class UserEditDiffsStep extends WorkflowStep<FileReference[], FileReference[]> {
|
|
5
|
-
private settings;
|
|
6
|
-
private spinner;
|
|
7
|
-
private completed;
|
|
8
|
-
constructor(settings: Settings);
|
|
9
|
-
run(files: FileReference[]): Promise<FileReference[]>;
|
|
10
|
-
wait(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { WorkflowStep } from './WorkflowStep.js';
|
|
2
|
-
import { logger } from '../../console/logger.js';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { collectAndSendUserEditDiffs } from '../../api/collectUserEditDiffs.js';
|
|
5
|
-
export class UserEditDiffsStep extends WorkflowStep {
|
|
6
|
-
settings;
|
|
7
|
-
spinner = logger.createSpinner('dots');
|
|
8
|
-
completed = false;
|
|
9
|
-
constructor(settings) {
|
|
10
|
-
super();
|
|
11
|
-
this.settings = settings;
|
|
12
|
-
}
|
|
13
|
-
async run(files) {
|
|
14
|
-
this.spinner.start('Updating translations...');
|
|
15
|
-
try {
|
|
16
|
-
await collectAndSendUserEditDiffs(files, this.settings);
|
|
17
|
-
this.completed = true;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
// Non-fatal; keep going to enqueue
|
|
21
|
-
this.completed = true;
|
|
22
|
-
}
|
|
23
|
-
return files;
|
|
24
|
-
}
|
|
25
|
-
async wait() {
|
|
26
|
-
if (this.completed) {
|
|
27
|
-
this.spinner.stop(chalk.green('Updated translations'));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|