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
package/dist/console/logger.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import { pino, destination } from 'pino';
|
|
4
|
-
import { log as clackLog, spinner, progress, intro, outro, } from '@clack/prompts';
|
|
5
|
-
// Mock spinner that logs to console instead of updating terminal UI
|
|
6
|
-
class MockSpinner {
|
|
7
|
-
currentMessage = '';
|
|
8
|
-
logger;
|
|
9
|
-
isCancelled = false;
|
|
10
|
-
constructor(logger) {
|
|
11
|
-
this.logger = logger;
|
|
12
|
-
}
|
|
13
|
-
start(message) {
|
|
14
|
-
if (message) {
|
|
15
|
-
this.currentMessage = message;
|
|
16
|
-
this.logger.info(`[Spinner] ${message}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
stop(message) {
|
|
20
|
-
const msg = message || this.currentMessage;
|
|
21
|
-
if (msg) {
|
|
22
|
-
this.logger.info(`[Spinner] ${msg}`);
|
|
23
|
-
}
|
|
24
|
-
this.currentMessage = '';
|
|
25
|
-
}
|
|
26
|
-
message(message) {
|
|
27
|
-
if (message) {
|
|
28
|
-
this.currentMessage = message;
|
|
29
|
-
this.logger.info(`[Spinner] ${message}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
// Mock progress bar that logs to console instead of updating terminal UI
|
|
34
|
-
class MockProgress {
|
|
35
|
-
max;
|
|
36
|
-
current = 0;
|
|
37
|
-
logger;
|
|
38
|
-
isCancelled = false;
|
|
39
|
-
constructor(max, logger) {
|
|
40
|
-
this.max = max;
|
|
41
|
-
this.logger = logger;
|
|
42
|
-
}
|
|
43
|
-
start(message) {
|
|
44
|
-
const msg = message || 'Starting progress';
|
|
45
|
-
this.logger.info(`[Progress] ${msg} (0/${this.max})`);
|
|
46
|
-
}
|
|
47
|
-
stop(message) {
|
|
48
|
-
const msg = message || 'Complete';
|
|
49
|
-
this.logger.info(`[Progress] ${msg} (${this.current}/${this.max})`);
|
|
50
|
-
}
|
|
51
|
-
message(message) {
|
|
52
|
-
if (message) {
|
|
53
|
-
this.logger.info(`[Progress] ${message} (${this.current}/${this.max})`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
advance(amount, message) {
|
|
57
|
-
this.current += amount;
|
|
58
|
-
const msg = message || 'Progress';
|
|
59
|
-
this.logger.info(`[Progress] ${msg} (${this.current}/${this.max})`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* GT_LOG_FORMAT: default | json.
|
|
64
|
-
* - If default, logs will be pretty-printed using @clack/prompts.
|
|
65
|
-
* - If json, logs will be written in JSON format to the console.
|
|
66
|
-
* GT_LOG_FILE: If specified, logs will be written to the file.
|
|
67
|
-
* GT_LOG_LEVEL: The level of logs to write. If not specified, defaults to 'info'.
|
|
68
|
-
* - Valid levels: debug, info, warn, error.
|
|
69
|
-
*/
|
|
70
|
-
class Logger {
|
|
71
|
-
static instance;
|
|
72
|
-
pinoLogger = null;
|
|
73
|
-
fileLogger = null;
|
|
74
|
-
logFormat;
|
|
75
|
-
constructor() {
|
|
76
|
-
// Read configuration from environment variables
|
|
77
|
-
const format = (process.env.GT_LOG_FORMAT || 'default').toLowerCase();
|
|
78
|
-
const logFile = process.env.GT_LOG_FILE;
|
|
79
|
-
const logLevel = process.env.GT_LOG_LEVEL || 'info';
|
|
80
|
-
if (format !== 'default' && format !== 'json') {
|
|
81
|
-
console.error('Invalid log format');
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
if (logLevel !== 'debug' &&
|
|
85
|
-
logLevel !== 'info' &&
|
|
86
|
-
logLevel !== 'warn' &&
|
|
87
|
-
logLevel !== 'error') {
|
|
88
|
-
console.error('Invalid log level');
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
this.logFormat = format;
|
|
92
|
-
// Console output (stdout) - only for JSON format
|
|
93
|
-
// For 'default' format, we use @clack/prompts directly
|
|
94
|
-
if (format === 'json') {
|
|
95
|
-
this.pinoLogger = pino({
|
|
96
|
-
level: logLevel,
|
|
97
|
-
mixin: () => ({
|
|
98
|
-
logId: randomUUID(),
|
|
99
|
-
}),
|
|
100
|
-
}, destination(1));
|
|
101
|
-
}
|
|
102
|
-
// File output (if specified) - always JSON format
|
|
103
|
-
if (logFile) {
|
|
104
|
-
this.fileLogger = pino({
|
|
105
|
-
level: logLevel,
|
|
106
|
-
mixin: () => ({
|
|
107
|
-
logId: randomUUID(),
|
|
108
|
-
}),
|
|
109
|
-
}, destination(logFile));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
static getInstance() {
|
|
113
|
-
if (!Logger.instance) {
|
|
114
|
-
Logger.instance = new Logger();
|
|
115
|
-
}
|
|
116
|
-
return Logger.instance;
|
|
117
|
-
}
|
|
118
|
-
// Standard logging methods
|
|
119
|
-
trace(message) {
|
|
120
|
-
if (this.logFormat === 'default') {
|
|
121
|
-
// @clack/prompts doesn't have trace, use message
|
|
122
|
-
clackLog.message(message, { symbol: chalk.dim('•') });
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
this.pinoLogger?.trace(message);
|
|
126
|
-
}
|
|
127
|
-
this.fileLogger?.trace(message);
|
|
128
|
-
}
|
|
129
|
-
debug(message) {
|
|
130
|
-
if (this.logFormat === 'default') {
|
|
131
|
-
// @clack/prompts doesn't have debug, use message
|
|
132
|
-
clackLog.message(message, { symbol: chalk.dim('◆') });
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this.pinoLogger?.debug(message);
|
|
136
|
-
}
|
|
137
|
-
this.fileLogger?.debug(message);
|
|
138
|
-
}
|
|
139
|
-
info(message) {
|
|
140
|
-
if (this.logFormat === 'default') {
|
|
141
|
-
clackLog.info(message);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
this.pinoLogger?.info(message);
|
|
145
|
-
}
|
|
146
|
-
this.fileLogger?.info(message);
|
|
147
|
-
}
|
|
148
|
-
warn(message) {
|
|
149
|
-
if (this.logFormat === 'default') {
|
|
150
|
-
clackLog.warn(message);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
this.pinoLogger?.warn(message);
|
|
154
|
-
}
|
|
155
|
-
this.fileLogger?.warn(message);
|
|
156
|
-
}
|
|
157
|
-
error(message) {
|
|
158
|
-
if (this.logFormat === 'default') {
|
|
159
|
-
clackLog.error(message);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
this.pinoLogger?.error(message);
|
|
163
|
-
}
|
|
164
|
-
this.fileLogger?.error(message);
|
|
165
|
-
}
|
|
166
|
-
fatal(message) {
|
|
167
|
-
if (this.logFormat === 'default') {
|
|
168
|
-
clackLog.error(message); // @clack/prompts doesn't have fatal, use error
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
this.pinoLogger?.fatal(message);
|
|
172
|
-
}
|
|
173
|
-
this.fileLogger?.fatal(message);
|
|
174
|
-
}
|
|
175
|
-
silent(message) {
|
|
176
|
-
// Silent doesn't log to console, only to file
|
|
177
|
-
this.fileLogger?.silent(message);
|
|
178
|
-
}
|
|
179
|
-
// @clack/prompts specific methods (for 'default' format)
|
|
180
|
-
success(message) {
|
|
181
|
-
if (this.logFormat === 'default') {
|
|
182
|
-
clackLog.success(message);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
this.pinoLogger?.info(message); // Map to info for non-default formats
|
|
186
|
-
}
|
|
187
|
-
this.fileLogger?.info(message);
|
|
188
|
-
}
|
|
189
|
-
step(message) {
|
|
190
|
-
if (this.logFormat === 'default') {
|
|
191
|
-
clackLog.step(message);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
this.pinoLogger?.info(message); // Map to info for non-default formats
|
|
195
|
-
}
|
|
196
|
-
this.fileLogger?.info(message);
|
|
197
|
-
}
|
|
198
|
-
message(message, symbol) {
|
|
199
|
-
if (this.logFormat === 'default') {
|
|
200
|
-
clackLog.message(message, symbol ? { symbol } : undefined);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
this.pinoLogger?.info(message); // Map to info for non-default formats
|
|
204
|
-
}
|
|
205
|
-
this.fileLogger?.info(message);
|
|
206
|
-
}
|
|
207
|
-
// Spinner functionality
|
|
208
|
-
createSpinner(indicator = 'timer') {
|
|
209
|
-
if (this.logFormat === 'default') {
|
|
210
|
-
return spinner({ indicator });
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
return new MockSpinner(this);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// Progress bar functionality
|
|
217
|
-
createProgressBar(total) {
|
|
218
|
-
if (this.logFormat === 'default') {
|
|
219
|
-
return progress({ max: total });
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
return new MockProgress(total, this);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// Command start/end markers
|
|
226
|
-
startCommand(message) {
|
|
227
|
-
if (this.logFormat === 'default') {
|
|
228
|
-
intro(chalk.cyan(message));
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
this.info(`╭─ ${message}`);
|
|
232
|
-
}
|
|
233
|
-
this.fileLogger?.info(`[START] ${message}`);
|
|
234
|
-
}
|
|
235
|
-
endCommand(message) {
|
|
236
|
-
if (this.logFormat === 'default') {
|
|
237
|
-
outro(chalk.cyan(message));
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
this.info(`╰─ ${message}`);
|
|
241
|
-
}
|
|
242
|
-
this.fileLogger?.info(`[END] ${message}`);
|
|
243
|
-
}
|
|
244
|
-
// Flush logs to ensure they're written before process exit
|
|
245
|
-
flush() {
|
|
246
|
-
this.pinoLogger?.flush();
|
|
247
|
-
this.fileLogger?.flush();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
export const logger = Logger.getInstance();
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { FileToUpload } from 'generaltranslation/types';
|
|
2
|
-
/**
|
|
3
|
-
* Strip ANSI escape codes from a string (e.g., chalk color codes)
|
|
4
|
-
*/
|
|
5
|
-
export declare function stripAnsi(str: string): string;
|
|
6
|
-
export declare function logErrorAndExit(message: string): never;
|
|
7
|
-
export declare function exitSync(code: number): never;
|
|
8
|
-
export declare function displayHeader(introString?: string): void;
|
|
9
|
-
export declare function displayProjectId(projectId: string): void;
|
|
10
|
-
export declare function displayResolvedPaths(resolvedPaths: [string, string][]): void;
|
|
11
|
-
export declare function displayCreatedConfigFile(configFilepath: string): void;
|
|
12
|
-
export declare function displayUpdatedConfigFile(configFilepath: string): void;
|
|
13
|
-
export declare function displayUpdatedVersionsFile(versionFilepath: string): void;
|
|
14
|
-
export declare function promptText({ message, defaultValue, validate, }: {
|
|
15
|
-
message: string;
|
|
16
|
-
defaultValue?: string;
|
|
17
|
-
validate?: (value: string) => boolean | string;
|
|
18
|
-
}): Promise<string>;
|
|
19
|
-
export declare function promptSelect<T>({ message, options, defaultValue, }: {
|
|
20
|
-
message: string;
|
|
21
|
-
options: Array<{
|
|
22
|
-
value: T;
|
|
23
|
-
label: string;
|
|
24
|
-
hint?: string;
|
|
25
|
-
}>;
|
|
26
|
-
defaultValue?: T;
|
|
27
|
-
}): Promise<T>;
|
|
28
|
-
export declare function promptMultiSelect<T extends string>({ message, options, required, }: {
|
|
29
|
-
message: string;
|
|
30
|
-
options: Array<{
|
|
31
|
-
value: T;
|
|
32
|
-
label: string;
|
|
33
|
-
hint?: string;
|
|
34
|
-
}>;
|
|
35
|
-
required?: boolean;
|
|
36
|
-
}): Promise<T[]>;
|
|
37
|
-
export declare function promptConfirm({ message, defaultValue, cancelMessage, }: {
|
|
38
|
-
message: string;
|
|
39
|
-
defaultValue?: boolean;
|
|
40
|
-
cancelMessage?: string;
|
|
41
|
-
}): Promise<boolean>;
|
|
42
|
-
export declare function warnApiKeyInConfig(optionsFilepath: string): void;
|
|
43
|
-
export declare function warnVariableProp(file: string, attrName: string, value: string): void;
|
|
44
|
-
export declare function warnNoId(file: string): void;
|
|
45
|
-
export declare function warnHasUnwrappedExpression(file: string, id: string, unwrappedExpressions: string[]): void;
|
|
46
|
-
export declare function warnNonStaticExpression(file: string, attrName: string, value: string): void;
|
|
47
|
-
export declare function warnTemplateLiteral(file: string, value: string): void;
|
|
48
|
-
export declare function warnTernary(file: string): void;
|
|
49
|
-
/**
|
|
50
|
-
* Helper: Log all collected files
|
|
51
|
-
*/
|
|
52
|
-
export declare function logCollectedFiles(files: Pick<FileToUpload, 'fileName'>[], reactComponents?: number): void;
|
package/dist/console/logging.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { text, select, confirm, isCancel, cancel, multiselect, } from '@clack/prompts';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { getCLIVersion } from '../utils/packageJson.js';
|
|
4
|
-
import { logger } from './logger.js';
|
|
5
|
-
import { TEMPLATE_FILE_NAME } from '../utils/constants.js';
|
|
6
|
-
/**
|
|
7
|
-
* Strip ANSI escape codes from a string (e.g., chalk color codes)
|
|
8
|
-
*/
|
|
9
|
-
export function stripAnsi(str) {
|
|
10
|
-
return str.replace(/\x1B\[[0-9;]*m/g, '');
|
|
11
|
-
}
|
|
12
|
-
export function logErrorAndExit(message) {
|
|
13
|
-
logger.error(message);
|
|
14
|
-
return exitSync(1);
|
|
15
|
-
}
|
|
16
|
-
export function exitSync(code) {
|
|
17
|
-
// Flush logs before exit
|
|
18
|
-
logger.flush();
|
|
19
|
-
process.exit(code);
|
|
20
|
-
}
|
|
21
|
-
// GT specific logging
|
|
22
|
-
export function displayHeader(introString) {
|
|
23
|
-
displayAsciiTitle();
|
|
24
|
-
displayInitializingText();
|
|
25
|
-
if (introString) {
|
|
26
|
-
logger.startCommand(introString);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function displayAsciiTitle() {
|
|
30
|
-
console.log(chalk.cyan(`\n ,ad8888ba, 888888888888
|
|
31
|
-
d8"' \`"8b 88
|
|
32
|
-
d8' 88
|
|
33
|
-
88 88
|
|
34
|
-
88 88888 88
|
|
35
|
-
Y8, 88 88
|
|
36
|
-
Y8a. .a88 88
|
|
37
|
-
\`"Y88888P" 88 `));
|
|
38
|
-
}
|
|
39
|
-
function displayInitializingText() {
|
|
40
|
-
const version = getCLIVersion();
|
|
41
|
-
console.log(`\n${chalk.bold.blue('General Translation, Inc.')}
|
|
42
|
-
${chalk.dim('https://generaltranslation.com/docs')}
|
|
43
|
-
${chalk.dim(`CLI Version: ${version}\n`)}`);
|
|
44
|
-
}
|
|
45
|
-
export function displayProjectId(projectId) {
|
|
46
|
-
logger.message(chalk.dim(`Project ID: ${chalk.bold(projectId)}`), chalk.cyan('~'));
|
|
47
|
-
}
|
|
48
|
-
export function displayResolvedPaths(resolvedPaths) {
|
|
49
|
-
const paths = resolvedPaths.map(([key, resolvedPath]) => {
|
|
50
|
-
return chalk.dim(`'${chalk.white(key)}' → '${chalk.green(resolvedPath)}'`);
|
|
51
|
-
});
|
|
52
|
-
logger.step(`Resolved path aliases:\n${paths.join('\n')}`);
|
|
53
|
-
}
|
|
54
|
-
export function displayCreatedConfigFile(configFilepath) {
|
|
55
|
-
logger.step(`Created config file ${chalk.cyan(configFilepath)}`);
|
|
56
|
-
}
|
|
57
|
-
export function displayUpdatedConfigFile(configFilepath) {
|
|
58
|
-
logger.success(`Updated config file ${chalk.cyan(configFilepath)}`);
|
|
59
|
-
}
|
|
60
|
-
export function displayUpdatedVersionsFile(versionFilepath) {
|
|
61
|
-
logger.success(`Updated versions file ${chalk.cyan(versionFilepath)}`);
|
|
62
|
-
}
|
|
63
|
-
// Input prompts
|
|
64
|
-
export async function promptText({ message, defaultValue, validate, }) {
|
|
65
|
-
const result = await text({
|
|
66
|
-
message,
|
|
67
|
-
placeholder: defaultValue,
|
|
68
|
-
validate: validate
|
|
69
|
-
? (value) => {
|
|
70
|
-
const validation = validate(value || '');
|
|
71
|
-
return validation === true ? undefined : validation.toString();
|
|
72
|
-
}
|
|
73
|
-
: undefined,
|
|
74
|
-
});
|
|
75
|
-
if (isCancel(result)) {
|
|
76
|
-
cancel('Operation cancelled');
|
|
77
|
-
return exitSync(0);
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
export async function promptSelect({ message, options, defaultValue, }) {
|
|
82
|
-
// Convert options to the format expected by clack
|
|
83
|
-
const clackOptions = options.map((opt) => ({
|
|
84
|
-
value: opt.value,
|
|
85
|
-
label: opt.label,
|
|
86
|
-
hint: opt.hint,
|
|
87
|
-
}));
|
|
88
|
-
const result = await select({
|
|
89
|
-
message,
|
|
90
|
-
options: clackOptions,
|
|
91
|
-
initialValue: defaultValue,
|
|
92
|
-
});
|
|
93
|
-
if (isCancel(result)) {
|
|
94
|
-
cancel('Operation cancelled');
|
|
95
|
-
return exitSync(0);
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
export async function promptMultiSelect({ message, options, required = true, }) {
|
|
100
|
-
// Convert options to the format expected by clack
|
|
101
|
-
const clackOptions = options.map((opt) => ({
|
|
102
|
-
value: opt.value,
|
|
103
|
-
label: opt.label,
|
|
104
|
-
hint: opt.hint,
|
|
105
|
-
}));
|
|
106
|
-
const result = await multiselect({
|
|
107
|
-
message,
|
|
108
|
-
options: clackOptions,
|
|
109
|
-
required,
|
|
110
|
-
});
|
|
111
|
-
if (isCancel(result)) {
|
|
112
|
-
cancel('Operation cancelled');
|
|
113
|
-
return exitSync(0);
|
|
114
|
-
}
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
export async function promptConfirm({ message, defaultValue = true, cancelMessage = 'Operation cancelled', }) {
|
|
118
|
-
const result = await confirm({
|
|
119
|
-
message,
|
|
120
|
-
initialValue: defaultValue,
|
|
121
|
-
});
|
|
122
|
-
if (isCancel(result)) {
|
|
123
|
-
cancel(cancelMessage);
|
|
124
|
-
return exitSync(0);
|
|
125
|
-
}
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
// Warning display functions
|
|
129
|
-
export function warnApiKeyInConfig(optionsFilepath) {
|
|
130
|
-
logger.warn(`Found ${chalk.cyan('apiKey')} in "${chalk.green(optionsFilepath)}". ` +
|
|
131
|
-
chalk.white('Your API key is exposed! Please remove it from the file and include it as an environment variable.'));
|
|
132
|
-
}
|
|
133
|
-
export function warnVariableProp(file, attrName, value) {
|
|
134
|
-
logger.warn(`Found ${chalk.green('<T>')} component in ${chalk.cyan(file)} with variable ${attrName}: "${chalk.white(value)}". ` +
|
|
135
|
-
`Change "${attrName}" to ensure this content is translated.`);
|
|
136
|
-
}
|
|
137
|
-
export function warnNoId(file) {
|
|
138
|
-
logger.warn(`Found ${chalk.green('<T>')} component in ${chalk.cyan(file)} with no id. ` +
|
|
139
|
-
chalk.white('Add an id to ensure the content is translated.'));
|
|
140
|
-
}
|
|
141
|
-
export function warnHasUnwrappedExpression(file, id, unwrappedExpressions) {
|
|
142
|
-
logger.warn(`${chalk.green('<T>')} with id "${id}" in ${chalk.cyan(file)} has children: ${unwrappedExpressions.join(', ')} that could change at runtime. ` +
|
|
143
|
-
chalk.white('Use a variable component like ') +
|
|
144
|
-
chalk.green('<Var>') +
|
|
145
|
-
chalk.white(' (') +
|
|
146
|
-
chalk.blue('https://generaltranslation.com/docs') +
|
|
147
|
-
chalk.white(') to translate this properly.'));
|
|
148
|
-
}
|
|
149
|
-
export function warnNonStaticExpression(file, attrName, value) {
|
|
150
|
-
logger.warn(`Found non-static expression in ${chalk.cyan(file)} for attribute ${attrName}: "${chalk.white(value)}". ` +
|
|
151
|
-
`Change "${attrName}" to ensure this content is translated.`);
|
|
152
|
-
}
|
|
153
|
-
export function warnTemplateLiteral(file, value) {
|
|
154
|
-
logger.warn(`Found template literal with quasis (${value}) in ${chalk.cyan(file)}. ` +
|
|
155
|
-
chalk.white('Change the template literal to a string to ensure this content is translated.'));
|
|
156
|
-
}
|
|
157
|
-
export function warnTernary(file) {
|
|
158
|
-
logger.warn(`Found ternary expression in ${chalk.cyan(file)}. ` +
|
|
159
|
-
chalk.white('A Branch component may be more appropriate here.'));
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Helper: Log all collected files
|
|
163
|
-
*/
|
|
164
|
-
export function logCollectedFiles(files, reactComponents) {
|
|
165
|
-
logger.message(chalk.cyan('Files found in project:') +
|
|
166
|
-
'\n' +
|
|
167
|
-
files
|
|
168
|
-
.map((file) => {
|
|
169
|
-
if (file.fileName === TEMPLATE_FILE_NAME) {
|
|
170
|
-
return `- <React Elements>${reactComponents ? ` (${reactComponents})` : ''}`;
|
|
171
|
-
}
|
|
172
|
-
return `- ${file.fileName}`;
|
|
173
|
-
})
|
|
174
|
-
.join('\n'));
|
|
175
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { logger } from '../../console/logger.js';
|
|
2
|
-
import { recordWarning } from '../../state/translateWarnings.js';
|
|
3
|
-
import { getRelative, readFile } from '../../fs/findFilepath.js';
|
|
4
|
-
import { SUPPORTED_FILE_EXTENSIONS } from './supportedFiles.js';
|
|
5
|
-
import { parseJson } from '../json/parseJson.js';
|
|
6
|
-
import parseYaml from '../yaml/parseYaml.js';
|
|
7
|
-
import YAML from 'yaml';
|
|
8
|
-
import { determineLibrary } from '../../fs/determineFramework.js';
|
|
9
|
-
import { hashStringSync } from '../../utils/hash.js';
|
|
10
|
-
import { preprocessContent } from './preprocessContent.js';
|
|
11
|
-
export const SUPPORTED_DATA_FORMATS = ['JSX', 'ICU', 'I18NEXT'];
|
|
12
|
-
export async function aggregateFiles(settings) {
|
|
13
|
-
// Aggregate all files to translate
|
|
14
|
-
const allFiles = [];
|
|
15
|
-
if (!settings.files ||
|
|
16
|
-
(Object.keys(settings.files.placeholderPaths).length === 1 &&
|
|
17
|
-
settings.files.placeholderPaths.gt)) {
|
|
18
|
-
return allFiles;
|
|
19
|
-
}
|
|
20
|
-
const { resolvedPaths: filePaths } = settings.files;
|
|
21
|
-
const skipValidation = settings.options?.skipFileValidation;
|
|
22
|
-
// Process JSON files
|
|
23
|
-
if (filePaths.json) {
|
|
24
|
-
const { library, additionalModules } = determineLibrary();
|
|
25
|
-
// Determine dataFormat for JSONs
|
|
26
|
-
let dataFormat;
|
|
27
|
-
if (library === 'next-intl') {
|
|
28
|
-
dataFormat = 'ICU';
|
|
29
|
-
}
|
|
30
|
-
else if (library === 'i18next') {
|
|
31
|
-
if (additionalModules.includes('i18next-icu')) {
|
|
32
|
-
dataFormat = 'ICU';
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
dataFormat = 'I18NEXT';
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
dataFormat = 'STRING';
|
|
40
|
-
}
|
|
41
|
-
const jsonFiles = filePaths.json
|
|
42
|
-
.map((filePath) => {
|
|
43
|
-
const content = readFile(filePath);
|
|
44
|
-
const relativePath = getRelative(filePath);
|
|
45
|
-
// Pre-validate JSON parseability
|
|
46
|
-
if (!skipValidation?.json) {
|
|
47
|
-
try {
|
|
48
|
-
JSON.parse(content);
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
logger.warn(`Skipping ${relativePath}: JSON file is not parsable`);
|
|
52
|
-
recordWarning('skipped_file', relativePath, 'JSON file is not parsable');
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const parsedJson = parseJson(content, filePath, settings.options || {}, settings.defaultLocale);
|
|
57
|
-
return {
|
|
58
|
-
fileId: hashStringSync(relativePath),
|
|
59
|
-
versionId: hashStringSync(parsedJson),
|
|
60
|
-
content: parsedJson,
|
|
61
|
-
fileName: relativePath,
|
|
62
|
-
fileFormat: 'JSON',
|
|
63
|
-
dataFormat,
|
|
64
|
-
locale: settings.defaultLocale,
|
|
65
|
-
};
|
|
66
|
-
})
|
|
67
|
-
.filter((file) => {
|
|
68
|
-
if (!file)
|
|
69
|
-
return false;
|
|
70
|
-
if (typeof file.content !== 'string' || !file.content.trim()) {
|
|
71
|
-
logger.warn(`Skipping ${file.fileName}: JSON file is empty`);
|
|
72
|
-
recordWarning('skipped_file', file.fileName, 'JSON file is empty');
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
});
|
|
77
|
-
allFiles.push(...jsonFiles.filter((file) => file !== null));
|
|
78
|
-
}
|
|
79
|
-
// Process YAML files
|
|
80
|
-
if (filePaths.yaml) {
|
|
81
|
-
const yamlFiles = filePaths.yaml
|
|
82
|
-
.map((filePath) => {
|
|
83
|
-
const content = readFile(filePath);
|
|
84
|
-
const relativePath = getRelative(filePath);
|
|
85
|
-
// Pre-validate YAML parseability
|
|
86
|
-
if (!skipValidation?.yaml) {
|
|
87
|
-
try {
|
|
88
|
-
YAML.parse(content);
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
logger.warn(`Skipping ${relativePath}: YAML file is not parsable`);
|
|
92
|
-
recordWarning('skipped_file', relativePath, 'YAML file is not parsable');
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, settings.options || {});
|
|
97
|
-
return {
|
|
98
|
-
content: parsedYaml,
|
|
99
|
-
fileName: relativePath,
|
|
100
|
-
fileFormat,
|
|
101
|
-
fileId: hashStringSync(relativePath),
|
|
102
|
-
versionId: hashStringSync(parsedYaml),
|
|
103
|
-
locale: settings.defaultLocale,
|
|
104
|
-
};
|
|
105
|
-
})
|
|
106
|
-
.filter((file) => {
|
|
107
|
-
if (!file || typeof file.content !== 'string' || !file.content.trim()) {
|
|
108
|
-
logger.warn(`Skipping ${file?.fileName ?? 'unknown'}: YAML file is empty`);
|
|
109
|
-
recordWarning('skipped_file', file?.fileName ?? 'unknown', 'YAML file is empty');
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
});
|
|
114
|
-
allFiles.push(...yamlFiles.filter((file) => file !== null));
|
|
115
|
-
}
|
|
116
|
-
for (const fileType of SUPPORTED_FILE_EXTENSIONS) {
|
|
117
|
-
if (fileType === 'json' || fileType === 'yaml')
|
|
118
|
-
continue;
|
|
119
|
-
if (filePaths[fileType]) {
|
|
120
|
-
const files = filePaths[fileType]
|
|
121
|
-
.map((filePath) => {
|
|
122
|
-
const content = readFile(filePath);
|
|
123
|
-
const relativePath = getRelative(filePath);
|
|
124
|
-
const processed = preprocessContent(content, relativePath, fileType, settings);
|
|
125
|
-
if (typeof processed !== 'string') {
|
|
126
|
-
logger.warn(`Skipping ${relativePath}: ${processed.skip}`);
|
|
127
|
-
recordWarning('skipped_file', relativePath, processed.skip);
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
content: processed,
|
|
132
|
-
fileName: relativePath,
|
|
133
|
-
fileFormat: fileType.toUpperCase(),
|
|
134
|
-
fileId: hashStringSync(relativePath),
|
|
135
|
-
versionId: hashStringSync(content),
|
|
136
|
-
locale: settings.defaultLocale,
|
|
137
|
-
};
|
|
138
|
-
})
|
|
139
|
-
.filter((file) => {
|
|
140
|
-
if (!file ||
|
|
141
|
-
typeof file.content !== 'string' ||
|
|
142
|
-
!file.content.trim()) {
|
|
143
|
-
logger.warn(`Skipping ${file?.fileName ?? 'unknown'}: File is empty after sanitization`);
|
|
144
|
-
recordWarning('skipped_file', file?.fileName ?? 'unknown', 'File is empty after sanitization');
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
return true;
|
|
148
|
-
});
|
|
149
|
-
allFiles.push(...files.filter((file) => file !== null));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (allFiles.length === 0 && !settings.publish) {
|
|
153
|
-
logger.error('No files to translate were found. Please check your configuration and try again.');
|
|
154
|
-
}
|
|
155
|
-
return allFiles;
|
|
156
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Settings, SupportedLibraries, TranslateFlags } from '../../types/index.js';
|
|
2
|
-
import type { FileToUpload } from 'generaltranslation/types';
|
|
3
|
-
export declare function collectFiles(options: TranslateFlags, settings: Settings, library: SupportedLibraries): Promise<{
|
|
4
|
-
files: FileToUpload[];
|
|
5
|
-
reactComponents: number;
|
|
6
|
-
}>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { logErrorAndExit } from '../../console/logging.js';
|
|
2
|
-
import { invalidConfigurationError } from '../../console/index.js';
|
|
3
|
-
import { aggregateFiles } from './aggregateFiles.js';
|
|
4
|
-
import { aggregateInlineTranslations } from '../../translation/stage.js';
|
|
5
|
-
import { hashStringSync } from '../../utils/hash.js';
|
|
6
|
-
import { TEMPLATE_FILE_NAME, TEMPLATE_FILE_ID } from '../../utils/constants.js';
|
|
7
|
-
import { isInlineLibrary } from '../../types/libraries.js';
|
|
8
|
-
export async function collectFiles(options, settings, library) {
|
|
9
|
-
// Aggregate files
|
|
10
|
-
const allFiles = await aggregateFiles(settings);
|
|
11
|
-
// Parse for React components
|
|
12
|
-
let reactComponents = 0;
|
|
13
|
-
if (isInlineLibrary(library)) {
|
|
14
|
-
const updates = await aggregateInlineTranslations(options, settings, library);
|
|
15
|
-
if (updates.length > 0) {
|
|
16
|
-
if (!settings.publish && !settings.files?.placeholderPaths.gt) {
|
|
17
|
-
logErrorAndExit(invalidConfigurationError);
|
|
18
|
-
}
|
|
19
|
-
// Convert updates to a file object
|
|
20
|
-
const fileData = {};
|
|
21
|
-
const fileMetadata = {};
|
|
22
|
-
// Convert updates to the proper data format
|
|
23
|
-
for (const update of updates) {
|
|
24
|
-
const { source, metadata, dataFormat } = update;
|
|
25
|
-
metadata.dataFormat = dataFormat; // add the data format to the metadata
|
|
26
|
-
const { hash, id } = metadata;
|
|
27
|
-
if (id) {
|
|
28
|
-
fileData[id] = source;
|
|
29
|
-
fileMetadata[id] = metadata;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
fileData[hash] = source;
|
|
33
|
-
fileMetadata[hash] = metadata;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
reactComponents = updates.length;
|
|
37
|
-
allFiles.push({
|
|
38
|
-
fileName: TEMPLATE_FILE_NAME,
|
|
39
|
-
content: JSON.stringify(fileData),
|
|
40
|
-
fileFormat: 'GTJSON',
|
|
41
|
-
formatMetadata: fileMetadata,
|
|
42
|
-
fileId: TEMPLATE_FILE_ID,
|
|
43
|
-
versionId: hashStringSync(JSON.stringify(Object.keys(fileData).sort())),
|
|
44
|
-
locale: settings.defaultLocale,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return { files: allFiles, reactComponents };
|
|
49
|
-
}
|