gtx-cli 2.6.29 → 2.6.30-alpha.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/README.md +12 -3
- package/dist/bin/bin-entry.js +2 -1
- 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/package.json +9 -60
- package/CHANGELOG.md +0 -1255
- 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/generateSettings.d.ts +0 -9
- package/dist/config/generateSettings.js +0 -214
- package/dist/config/optionPresets.d.ts +0 -3
- package/dist/config/optionPresets.js +0 -65
- package/dist/config/resolveConfig.d.ts +0 -4
- package/dist/config/resolveConfig.js +0 -33
- 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 -33
- package/dist/console/index.js +0 -44
- 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 -173
- 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/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/setupConfig.d.ts +0 -17
- package/dist/fs/config/setupConfig.js +0 -50
- 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/matchFiles.d.ts +0 -1
- package/dist/fs/matchFiles.js +0 -8
- 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/next/parse/handleInitGT.d.ts +0 -7
- package/dist/next/parse/handleInitGT.js +0 -157
- package/dist/next/parse/wrapContent.d.ts +0 -12
- package/dist/next/parse/wrapContent.js +0 -164
- 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 -13
- package/dist/react/jsx/utils/constants.js +0 -46
- 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 -135
- 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 -912
- 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/parse/wrapContent.d.ts +0 -12
- package/dist/react/parse/wrapContent.js +0 -162
- 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/index.d.ts +0 -243
- package/dist/types/index.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/installPackage.d.ts +0 -3
- package/dist/utils/installPackage.js +0 -77
- 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/packageInfo.d.ts +0 -3
- package/dist/utils/packageInfo.js +0 -17
- package/dist/utils/packageJson.d.ts +0 -6
- package/dist/utils/packageJson.js +0 -68
- package/dist/utils/packageManager.d.ts +0 -28
- package/dist/utils/packageManager.js +0 -269
- 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/workflows/download.d.ts +0 -32
- package/dist/workflows/download.js +0 -127
- 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,150 +0,0 @@
|
|
|
1
|
-
import { getLocaleProperties } from 'generaltranslation';
|
|
2
|
-
import { exitSync } from '../../console/logging.js';
|
|
3
|
-
import { logger } from '../../console/logger.js';
|
|
4
|
-
import { JSONPath } from 'jsonpath-plus';
|
|
5
|
-
import { flattenJson } from './flattenJson.js';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import micromatch from 'micromatch';
|
|
8
|
-
const { isMatch } = micromatch;
|
|
9
|
-
// Find the matching source item in an array
|
|
10
|
-
// where the key matches the identifying locale property
|
|
11
|
-
// If no matching item is found, exit with an error
|
|
12
|
-
export function findMatchingItemArray(locale, sourceObjectOptions, sourceObjectPointer, sourceObjectValue) {
|
|
13
|
-
const { identifyingLocaleProperty, localeKeyJsonPath } = getSourceObjectOptionsArray(locale, sourceObjectPointer, sourceObjectOptions);
|
|
14
|
-
// Use the json pointer key to locate the source item
|
|
15
|
-
const matchingItems = {};
|
|
16
|
-
for (const [index, item] of sourceObjectValue.entries()) {
|
|
17
|
-
// Get the key candidates
|
|
18
|
-
const keyCandidates = JSONPath({
|
|
19
|
-
json: item,
|
|
20
|
-
path: localeKeyJsonPath,
|
|
21
|
-
resultType: 'all',
|
|
22
|
-
flatten: true,
|
|
23
|
-
wrap: true,
|
|
24
|
-
});
|
|
25
|
-
if (!keyCandidates) {
|
|
26
|
-
logger.error(`Source item at path: ${sourceObjectPointer} does not have a key value at path: ${localeKeyJsonPath}`);
|
|
27
|
-
return exitSync(1);
|
|
28
|
-
}
|
|
29
|
-
else if (keyCandidates.length === 0) {
|
|
30
|
-
// If no key candidates, skip the item
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
else if (keyCandidates.length > 1) {
|
|
34
|
-
// If multiple key candidates, exit with an error
|
|
35
|
-
logger.error(`Source item at path: ${sourceObjectPointer} has multiple matching keys with path: ${localeKeyJsonPath}`);
|
|
36
|
-
return exitSync(1);
|
|
37
|
-
}
|
|
38
|
-
else if (identifyingLocaleProperty !== keyCandidates[0].value) {
|
|
39
|
-
// Validate the key is the identifying locale property
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
// Map the index to the source item
|
|
43
|
-
matchingItems[`/${index}`] = {
|
|
44
|
-
sourceItem: item,
|
|
45
|
-
keyParentProperty: keyCandidates[0].parentProperty,
|
|
46
|
-
keyPointer: keyCandidates[0].pointer,
|
|
47
|
-
index,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return matchingItems;
|
|
51
|
-
}
|
|
52
|
-
export function findMatchingItemObject(locale, sourceObjectPointer, sourceObjectOptions, sourceObjectValue) {
|
|
53
|
-
const { identifyingLocaleProperty } = getSourceObjectOptionsObject(locale, sourceObjectPointer, sourceObjectOptions);
|
|
54
|
-
// Locate the source item
|
|
55
|
-
if (sourceObjectValue[identifyingLocaleProperty]) {
|
|
56
|
-
return {
|
|
57
|
-
sourceItem: sourceObjectValue[identifyingLocaleProperty],
|
|
58
|
-
keyParentProperty: identifyingLocaleProperty,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
sourceItem: undefined,
|
|
63
|
-
keyParentProperty: identifyingLocaleProperty,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get the identifying locale property for an object
|
|
68
|
-
* @param locale - The locale to get the identifying locale property for
|
|
69
|
-
* @param sourceObjectPointer - The path to the source object
|
|
70
|
-
* @param sourceObjectOptions - The source object options
|
|
71
|
-
* @returns The identifying locale property
|
|
72
|
-
*/
|
|
73
|
-
export function getIdentifyingLocaleProperty(locale, sourceObjectPointer, sourceObjectOptions) {
|
|
74
|
-
// Validate localeProperty
|
|
75
|
-
const localeProperty = sourceObjectOptions.localeProperty || 'code';
|
|
76
|
-
const identifyingLocaleProperty = getLocaleProperties(locale)[localeProperty];
|
|
77
|
-
if (!identifyingLocaleProperty) {
|
|
78
|
-
logger.error(`Source object options localeProperty is not a valid locale property at path: ${sourceObjectPointer}`);
|
|
79
|
-
return exitSync(1);
|
|
80
|
-
}
|
|
81
|
-
return identifyingLocaleProperty;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Get the identifying locale property and the json path to the key for an array
|
|
85
|
-
* @param locale - The locale to get the identifying locale property for
|
|
86
|
-
* @param sourceObjectPointer - The path to the source object
|
|
87
|
-
* @param sourceObjectOptions - The source object options
|
|
88
|
-
* @returns The identifying locale property and the json path to the key
|
|
89
|
-
*/
|
|
90
|
-
export function getSourceObjectOptionsArray(locale, sourceObjectPointer, sourceObjectOptions) {
|
|
91
|
-
const identifyingLocaleProperty = getIdentifyingLocaleProperty(locale, sourceObjectPointer, sourceObjectOptions);
|
|
92
|
-
const localeKeyJsonPath = sourceObjectOptions.key;
|
|
93
|
-
if (!localeKeyJsonPath) {
|
|
94
|
-
logger.error(`Source object options key is required for array at path: ${sourceObjectPointer}`);
|
|
95
|
-
return exitSync(1);
|
|
96
|
-
}
|
|
97
|
-
return { identifyingLocaleProperty, localeKeyJsonPath };
|
|
98
|
-
}
|
|
99
|
-
export function getSourceObjectOptionsObject(defaultLocale, sourceObjectPointer, sourceObjectOptions) {
|
|
100
|
-
const identifyingLocaleProperty = getIdentifyingLocaleProperty(defaultLocale, sourceObjectPointer, sourceObjectOptions);
|
|
101
|
-
const jsonPathKey = sourceObjectOptions.key;
|
|
102
|
-
if (jsonPathKey) {
|
|
103
|
-
logger.error(`Source object options key is not allowed for object at path: ${sourceObjectPointer}`);
|
|
104
|
-
return exitSync(1);
|
|
105
|
-
}
|
|
106
|
-
return { identifyingLocaleProperty };
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Generate a mapping of sourceObjectPointer to SourceObjectOptions
|
|
110
|
-
* where the sourceObjectPointer is a jsonpointer to the array or object containing
|
|
111
|
-
* @param jsonSchema - The json schema to generate the mapping from
|
|
112
|
-
* @param originalJson - The original json to generate the mapping from
|
|
113
|
-
* @returns A mapping of sourceObjectPointer to SourceObjectOptions
|
|
114
|
-
*/
|
|
115
|
-
export function generateSourceObjectPointers(jsonSchema, originalJson) {
|
|
116
|
-
const sourceObjectPointers = Object.entries(jsonSchema).reduce((acc, [sourceObjectPath, sourceObjectOptions]) => {
|
|
117
|
-
const sourceObjects = flattenJson(originalJson, [sourceObjectPath]);
|
|
118
|
-
Object.entries(sourceObjects).forEach(([pointer, value]) => {
|
|
119
|
-
acc[pointer] = {
|
|
120
|
-
sourceObjectValue: value,
|
|
121
|
-
sourceObjectOptions,
|
|
122
|
-
};
|
|
123
|
-
});
|
|
124
|
-
return acc;
|
|
125
|
-
}, {});
|
|
126
|
-
return sourceObjectPointers;
|
|
127
|
-
}
|
|
128
|
-
export function validateJsonSchema(options, filePath) {
|
|
129
|
-
if (!options.jsonSchema) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
const fileGlobs = Object.keys(options.jsonSchema);
|
|
133
|
-
const matchingGlob = fileGlobs.find((fileGlob) => isMatch(path.relative(process.cwd(), filePath), fileGlob));
|
|
134
|
-
if (!matchingGlob || !options.jsonSchema[matchingGlob]) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
// Validate includes or composite
|
|
138
|
-
const jsonSchema = options.jsonSchema[matchingGlob];
|
|
139
|
-
if (jsonSchema.include && jsonSchema.composite) {
|
|
140
|
-
logger.error('include and composite cannot be used together in the same JSON schema');
|
|
141
|
-
return exitSync(1);
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
if (!jsonSchema.include && !jsonSchema.composite) {
|
|
145
|
-
logger.error('No include or composite property found in JSON schema');
|
|
146
|
-
return exitSync(1);
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
return jsonSchema;
|
|
150
|
-
}
|
package/dist/formats/utils.d.ts
DELETED
package/dist/formats/utils.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// helper function to replace locale placeholders in a string
|
|
2
|
-
// with the corresponding locale properties
|
|
3
|
-
// ex: {locale} -> will be replaced with the locale code
|
|
4
|
-
// ex: {localeName} -> will be replaced with the locale name
|
|
5
|
-
export function replaceLocalePlaceholders(string, localeProperties) {
|
|
6
|
-
return string.replace(/\{(\w+)\}/g, (match, property) => {
|
|
7
|
-
// Handle common aliases
|
|
8
|
-
if (property === 'locale' || property === 'localeCode') {
|
|
9
|
-
return localeProperties.code;
|
|
10
|
-
}
|
|
11
|
-
if (property === 'localeName') {
|
|
12
|
-
return localeProperties.name;
|
|
13
|
-
}
|
|
14
|
-
if (property === 'localeNativeName') {
|
|
15
|
-
return localeProperties.nativeName;
|
|
16
|
-
}
|
|
17
|
-
// Check if the property exists in localeProperties
|
|
18
|
-
if (property in localeProperties) {
|
|
19
|
-
return localeProperties[property];
|
|
20
|
-
}
|
|
21
|
-
// Return the original placeholder if property not found
|
|
22
|
-
return match;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import JSONPointer from 'jsonpointer';
|
|
2
|
-
import { exitSync } from '../../console/logging.js';
|
|
3
|
-
import { logger } from '../../console/logger.js';
|
|
4
|
-
import { validateYamlSchema } from './utils.js';
|
|
5
|
-
import YAML from 'yaml';
|
|
6
|
-
import { applyTransformations } from '../json/mergeJson.js';
|
|
7
|
-
export default function mergeYaml(originalContent, inputPath, options, targets, defaultLocale) {
|
|
8
|
-
const yamlSchema = validateYamlSchema(options, inputPath);
|
|
9
|
-
if (!yamlSchema) {
|
|
10
|
-
return targets.map((target) => target.translatedContent);
|
|
11
|
-
}
|
|
12
|
-
let originalYaml;
|
|
13
|
-
try {
|
|
14
|
-
originalYaml = YAML.parse(originalContent);
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
logger.error(`Invalid YAML file: ${inputPath}`);
|
|
18
|
-
return exitSync(1);
|
|
19
|
-
}
|
|
20
|
-
// Unreachable (validated in validateYamlSchema, included for type check)
|
|
21
|
-
if (!yamlSchema.include) {
|
|
22
|
-
logger.error('No include property found in YAML schema');
|
|
23
|
-
return exitSync(1);
|
|
24
|
-
}
|
|
25
|
-
// Handle include
|
|
26
|
-
const output = [];
|
|
27
|
-
for (const target of targets) {
|
|
28
|
-
// Must clone the original YAML to avoid mutations
|
|
29
|
-
const mergedYaml = JSON.parse(JSON.stringify(originalYaml));
|
|
30
|
-
let translatedJson;
|
|
31
|
-
try {
|
|
32
|
-
translatedJson = JSON.parse(target.translatedContent);
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
// If parsing fails, treat as empty object to avoid crashes
|
|
36
|
-
translatedJson = {};
|
|
37
|
-
}
|
|
38
|
-
for (const [jsonPointer, translatedValue] of Object.entries(translatedJson)) {
|
|
39
|
-
try {
|
|
40
|
-
// Try to get the value - if this succeeds, the pointer exists
|
|
41
|
-
if (JSONPointer.get(mergedYaml, jsonPointer) == null) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
// Set the new value regardless of what the current value is (including null/falsy)
|
|
45
|
-
JSONPointer.set(mergedYaml, jsonPointer, translatedValue);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
// Silently ignore invalid or non-existent JSON pointers
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// Apply transformations if they exist
|
|
52
|
-
if (yamlSchema.transform) {
|
|
53
|
-
applyTransformations(mergedYaml, yamlSchema.transform, target.targetLocale, defaultLocale);
|
|
54
|
-
}
|
|
55
|
-
output.push(YAML.stringify(mergedYaml));
|
|
56
|
-
}
|
|
57
|
-
if (!output.length) {
|
|
58
|
-
return [originalContent];
|
|
59
|
-
}
|
|
60
|
-
return output;
|
|
61
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { exitSync } from '../../console/logging.js';
|
|
2
|
-
import { logger } from '../../console/logger.js';
|
|
3
|
-
import YAML from 'yaml';
|
|
4
|
-
import { validateYamlSchema } from './utils.js';
|
|
5
|
-
import { flattenJsonWithStringFilter } from '../json/flattenJson.js';
|
|
6
|
-
export default function parseYaml(content, filePath, options) {
|
|
7
|
-
const yamlSchema = validateYamlSchema(options, filePath);
|
|
8
|
-
if (!yamlSchema) {
|
|
9
|
-
return { content, fileFormat: 'YAML' };
|
|
10
|
-
}
|
|
11
|
-
let yaml;
|
|
12
|
-
try {
|
|
13
|
-
yaml = YAML.parse(content);
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
logger.error(`Invalid YAML file: ${filePath}`);
|
|
17
|
-
return exitSync(1);
|
|
18
|
-
}
|
|
19
|
-
if (yamlSchema.include) {
|
|
20
|
-
const flattenedYaml = flattenJsonWithStringFilter(yaml, yamlSchema.include);
|
|
21
|
-
return { content: JSON.stringify(flattenedYaml), fileFormat: 'JSON' };
|
|
22
|
-
}
|
|
23
|
-
return { content, fileFormat: 'YAML' };
|
|
24
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { exitSync } from '../../console/logging.js';
|
|
2
|
-
import { logger } from '../../console/logger.js';
|
|
3
|
-
import micromatch from 'micromatch';
|
|
4
|
-
const { isMatch } = micromatch;
|
|
5
|
-
import path from 'path';
|
|
6
|
-
export function validateYamlSchema(options, filePath) {
|
|
7
|
-
if (!options.yamlSchema) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
// Check if the file matches any of the yaml schema globs
|
|
11
|
-
const fileGlobs = Object.keys(options.yamlSchema);
|
|
12
|
-
const matchingGlob = fileGlobs.find((fileGlob) => isMatch(path.relative(process.cwd(), filePath), fileGlob));
|
|
13
|
-
if (!matchingGlob || !options.yamlSchema[matchingGlob]) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
// Validate includes
|
|
17
|
-
const yamlSchema = options.yamlSchema[matchingGlob];
|
|
18
|
-
if (!yamlSchema.include) {
|
|
19
|
-
logger.error('No include property found in YAML schema');
|
|
20
|
-
return exitSync(1);
|
|
21
|
-
}
|
|
22
|
-
return yamlSchema;
|
|
23
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clears translated files before writing new translations
|
|
3
|
-
* @param filePaths - Set of translated file paths to clear
|
|
4
|
-
* @param locales - Array of locale codes to match against
|
|
5
|
-
* @param excludePatterns - Optional array of glob patterns to exclude from clearing (supports [locale] and [locales])
|
|
6
|
-
* @param cwd - Current working directory for resolving relative exclude patterns (defaults to process.cwd())
|
|
7
|
-
*/
|
|
8
|
-
export declare function clearLocaleDirs(filePaths: Set<string>, locales: string[], excludePatterns?: string[], cwd?: string): Promise<void>;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { logger } from '../console/logger.js';
|
|
4
|
-
import fg from 'fast-glob';
|
|
5
|
-
import micromatch from 'micromatch';
|
|
6
|
-
/**
|
|
7
|
-
* Extracts locale directories from translated file paths.
|
|
8
|
-
* Groups files by their immediate parent containing a locale code.
|
|
9
|
-
* For example: "snippets/es/api-test/file.mdx" -> "snippets/es"
|
|
10
|
-
*/
|
|
11
|
-
function extractLocaleDirectories(filePaths, locales) {
|
|
12
|
-
const localeDirs = new Set();
|
|
13
|
-
const localeSet = new Set(locales);
|
|
14
|
-
for (const filePath of filePaths) {
|
|
15
|
-
const parts = filePath.split(path.sep);
|
|
16
|
-
// Find directory segments that match the provided locales
|
|
17
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
18
|
-
const segment = parts[i];
|
|
19
|
-
if (localeSet.has(segment)) {
|
|
20
|
-
// Found a locale directory, capture up to and including this segment
|
|
21
|
-
const localeDir = parts.slice(0, i + 1).join(path.sep);
|
|
22
|
-
localeDirs.add(localeDir);
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return localeDirs;
|
|
28
|
-
}
|
|
29
|
-
async function getAllFiles(dirPath) {
|
|
30
|
-
return await fg(path.join(dirPath, '**/*'), {
|
|
31
|
-
absolute: true,
|
|
32
|
-
onlyFiles: true,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
async function getFilesToDelete(dirPath, excludePatterns, currentLocale, cwd) {
|
|
36
|
-
const allFiles = await getAllFiles(dirPath);
|
|
37
|
-
const absoluteCwd = path.resolve(cwd);
|
|
38
|
-
const expandedExcludePatterns = excludePatterns.map((p) => {
|
|
39
|
-
const resolvedPattern = path.isAbsolute(p) ? p : path.join(absoluteCwd, p);
|
|
40
|
-
return resolvedPattern
|
|
41
|
-
.replace(/\[locale\]/g, currentLocale)
|
|
42
|
-
.replace(/\[locales\]/g, currentLocale);
|
|
43
|
-
});
|
|
44
|
-
const filesToKeep = micromatch(allFiles, expandedExcludePatterns, {
|
|
45
|
-
dot: true,
|
|
46
|
-
});
|
|
47
|
-
const filesToKeepSet = new Set(filesToKeep);
|
|
48
|
-
return allFiles.filter((file) => !filesToKeepSet.has(file));
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Clears translated files before writing new translations
|
|
52
|
-
* @param filePaths - Set of translated file paths to clear
|
|
53
|
-
* @param locales - Array of locale codes to match against
|
|
54
|
-
* @param excludePatterns - Optional array of glob patterns to exclude from clearing (supports [locale] and [locales])
|
|
55
|
-
* @param cwd - Current working directory for resolving relative exclude patterns (defaults to process.cwd())
|
|
56
|
-
*/
|
|
57
|
-
export async function clearLocaleDirs(filePaths, locales, excludePatterns, cwd = process.cwd()) {
|
|
58
|
-
// Extract locale directories
|
|
59
|
-
const localeDirs = extractLocaleDirectories(filePaths, locales);
|
|
60
|
-
for (const dir of localeDirs) {
|
|
61
|
-
try {
|
|
62
|
-
await fs.stat(dir);
|
|
63
|
-
// Extract locale from directory path
|
|
64
|
-
const dirParts = dir.split(path.sep);
|
|
65
|
-
const locale = locales.find((loc) => dirParts.includes(loc));
|
|
66
|
-
if (!locale) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
if (!excludePatterns?.length) {
|
|
70
|
-
await fs.rm(dir, { recursive: true, force: true });
|
|
71
|
-
logger.success(`Cleared locale directory: ${dir}`);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const filesToDelete = await getFilesToDelete(dir, excludePatterns, locale, cwd);
|
|
75
|
-
// Get all files for count comparison
|
|
76
|
-
const allFiles = await getAllFiles(dir);
|
|
77
|
-
for (const file of filesToDelete) {
|
|
78
|
-
try {
|
|
79
|
-
await fs.unlink(file);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
if (error.code !== 'ENOENT') {
|
|
83
|
-
logger.warn(`Failed to delete file ${file}: ${error}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// Clean up empty directories
|
|
88
|
-
await cleanupEmptyDirs(dir);
|
|
89
|
-
const excludedCount = allFiles.length - filesToDelete.length;
|
|
90
|
-
if (excludedCount > 0) {
|
|
91
|
-
logger.success(`Cleared locale directory: ${dir} (excluded ${excludedCount} file${excludedCount > 1 ? 's' : ''})`);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
logger.success(`Cleared locale directory: ${dir}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
if (error.code !== 'ENOENT') {
|
|
99
|
-
logger.warn(`Failed to clear locale directory ${dir}: ${error}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Recursively removes empty directories
|
|
106
|
-
* @param dirPath - The directory to clean up
|
|
107
|
-
*/
|
|
108
|
-
async function cleanupEmptyDirs(dirPath) {
|
|
109
|
-
try {
|
|
110
|
-
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
111
|
-
// Recursively clean subdirectories first
|
|
112
|
-
for (const entry of entries) {
|
|
113
|
-
if (entry.isDirectory()) {
|
|
114
|
-
await cleanupEmptyDirs(path.join(dirPath, entry.name));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// Check if directory is now empty
|
|
118
|
-
const remainingEntries = await fs.readdir(dirPath);
|
|
119
|
-
if (remainingEntries.length === 0) {
|
|
120
|
-
await fs.rmdir(dirPath);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
// Ignore errors - directory might not exist or might not be empty
|
|
125
|
-
}
|
|
126
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type DownloadedVersionEntry = {
|
|
2
|
-
fileName?: string;
|
|
3
|
-
updatedAt?: string;
|
|
4
|
-
postProcessHash?: string;
|
|
5
|
-
sourceHash?: string;
|
|
6
|
-
};
|
|
7
|
-
export type DownloadedVersions = {
|
|
8
|
-
version: number;
|
|
9
|
-
entries: {
|
|
10
|
-
[branchId: string]: {
|
|
11
|
-
[fileId: string]: {
|
|
12
|
-
[versionId: string]: {
|
|
13
|
-
[locale: string]: DownloadedVersionEntry;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare function getDownloadedVersions(configDirectory: string): DownloadedVersions;
|
|
20
|
-
export declare function saveDownloadedVersions(configDirectory: string, lock: DownloadedVersions): void;
|
|
21
|
-
export declare function ensureNestedObject(obj: any, path: string[]): any;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { logger } from '../../console/logger.js';
|
|
4
|
-
// New lock file name, use old name for deletion of legacy lock file
|
|
5
|
-
const GT_LOCK_FILE = 'gt-lock.json';
|
|
6
|
-
const LEGACY_DOWNLOADED_VERSIONS_FILE = 'downloaded-versions.json';
|
|
7
|
-
export function getDownloadedVersions(configDirectory) {
|
|
8
|
-
try {
|
|
9
|
-
// Clean up legacy lock files inside the config directory
|
|
10
|
-
const rootPath = path.join(process.cwd(), GT_LOCK_FILE);
|
|
11
|
-
const legacyPath = path.join(configDirectory, LEGACY_DOWNLOADED_VERSIONS_FILE);
|
|
12
|
-
try {
|
|
13
|
-
if (fs.existsSync(legacyPath)) {
|
|
14
|
-
fs.unlinkSync(legacyPath);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
catch { }
|
|
18
|
-
const filepath = fs.existsSync(rootPath) ? rootPath : null;
|
|
19
|
-
if (!filepath)
|
|
20
|
-
return { version: 1, entries: {} };
|
|
21
|
-
const raw = JSON.parse(fs.readFileSync(filepath, 'utf8'));
|
|
22
|
-
if (raw && typeof raw === 'object' && raw.version && raw.entries) {
|
|
23
|
-
return raw;
|
|
24
|
-
}
|
|
25
|
-
return { version: 1, entries: {} };
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
logger.error(`An error occurred while getting downloaded versions: ${error}`);
|
|
29
|
-
return { version: 1, entries: {} };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export function saveDownloadedVersions(configDirectory, lock) {
|
|
33
|
-
try {
|
|
34
|
-
// Write the lock file to the repo root
|
|
35
|
-
const filepath = path.join(process.cwd(), GT_LOCK_FILE);
|
|
36
|
-
fs.mkdirSync(path.dirname(filepath), { recursive: true });
|
|
37
|
-
fs.writeFileSync(filepath, JSON.stringify(lock, null, 2));
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
logger.error(`An error occurred while updating ${GT_LOCK_FILE}: ${error}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export function ensureNestedObject(obj, path) {
|
|
44
|
-
return path.reduce((current, key, index) => {
|
|
45
|
-
if (index === path.length - 1)
|
|
46
|
-
return current;
|
|
47
|
-
current[key] = current[key] || {};
|
|
48
|
-
return current[key];
|
|
49
|
-
}, obj);
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function loadConfig(filepath: string): Record<string, any>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { FilesOptions, ResolvedFiles, TransformFiles, TransformOption } from '../../types/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Resolves the files from the files object
|
|
4
|
-
* Replaces [locale] with the actual locale in the files
|
|
5
|
-
*
|
|
6
|
-
* @param files - The files object
|
|
7
|
-
* @param locale - The locale to replace [locale] with
|
|
8
|
-
* @returns The resolved files
|
|
9
|
-
*/
|
|
10
|
-
export declare function resolveLocaleFiles(files: ResolvedFiles, locale: string): ResolvedFiles;
|
|
11
|
-
/**
|
|
12
|
-
* Resolves the files from the files object
|
|
13
|
-
* Performs glob pattern expansion on the files
|
|
14
|
-
* Replaces [locale] with the actual locale in the files
|
|
15
|
-
*
|
|
16
|
-
* @param files - The files object
|
|
17
|
-
* @returns The resolved files
|
|
18
|
-
*/
|
|
19
|
-
export declare function resolveFiles(files: FilesOptions, locale: string, locales: string[], cwd: string, compositePatterns?: string[]): {
|
|
20
|
-
resolvedPaths: ResolvedFiles;
|
|
21
|
-
placeholderPaths: ResolvedFiles;
|
|
22
|
-
transformPaths: TransformFiles;
|
|
23
|
-
};
|
|
24
|
-
export declare function expandGlobPatterns(cwd: string, includePatterns: string[], excludePatterns: string[], locale: string, locales: string[], transformPatterns?: TransformOption | string | TransformOption[], compositePatterns?: string[]): {
|
|
25
|
-
resolvedPaths: string[];
|
|
26
|
-
placeholderPaths: string[];
|
|
27
|
-
};
|