gt 2.15.0 → 2.16.1
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 +30 -0
- package/dist/api/downloadFileBatch.js +28 -1
- package/dist/api/downloadFileBatch.js.map +1 -1
- package/dist/cli/base.js +16 -0
- package/dist/cli/base.js.map +1 -1
- package/dist/cli/commands/download.js +2 -1
- package/dist/cli/commands/download.js.map +1 -1
- package/dist/cli/commands/upload.js +5 -3
- package/dist/cli/commands/upload.js.map +1 -1
- package/dist/cli/flags.js +1 -1
- package/dist/cli/flags.js.map +1 -1
- package/dist/console/index.d.ts +3 -0
- package/dist/console/index.js +4 -1
- package/dist/console/index.js.map +1 -1
- package/dist/formats/files/aggregateFiles.js +32 -2
- package/dist/formats/files/aggregateFiles.js.map +1 -1
- package/dist/formats/files/collectFonts.d.ts +7 -0
- package/dist/formats/files/collectFonts.js +30 -0
- package/dist/formats/files/collectFonts.js.map +1 -0
- package/dist/formats/files/detectLottieExpressions.d.ts +8 -0
- package/dist/formats/files/detectLottieExpressions.js +42 -0
- package/dist/formats/files/detectLottieExpressions.js.map +1 -0
- package/dist/formats/files/supportedFiles.d.ts +2 -1
- package/dist/formats/files/supportedFiles.js +4 -2
- package/dist/formats/files/supportedFiles.js.map +1 -1
- package/dist/formats/files/transformFormat.d.ts +2 -0
- package/dist/formats/files/transformFormat.js +6 -3
- package/dist/formats/files/transformFormat.js.map +1 -1
- package/dist/fs/findFilepath.d.ts +7 -0
- package/dist/fs/findFilepath.js +11 -1
- package/dist/fs/findFilepath.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/generated/version.js.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/workflows/enqueue.js +2 -0
- package/dist/workflows/enqueue.js.map +1 -1
- package/dist/workflows/stage.js +2 -0
- package/dist/workflows/stage.js.map +1 -1
- package/dist/workflows/upload.js +2 -0
- package/dist/workflows/upload.js.map +1 -1
- package/dist/workflows/utils/syncFonts.d.ts +9 -0
- package/dist/workflows/utils/syncFonts.js +25 -0
- package/dist/workflows/utils/syncFonts.js.map +1 -0
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findFilepath.js","names":[],"sources":["../../src/fs/findFilepath.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../console/logger.js';\nimport { exitSync } from '../console/logging.js';\n\n/**\n * Resolve the file path from the given file path or default paths.\n * @param {string} filePath - The file path to resolve.\n * @param {string[]} defaultPaths - The default paths to check.\n * @returns {string} - The resolved file path.\n */\nexport default function findFilepath(\n paths: string[],\n errorMessage: string = ''\n): string {\n return findFilepaths(paths, errorMessage)?.[0] || '';\n}\n\n/**\n * Resolve the file paths from the given file paths or default paths.\n * @param {string[]} paths - The file paths to resolve.\n * @param {string} errorMessage - The error message to throw if no paths are found.\n * @returns {string[]} - The resolved file paths.\n */\nexport function findFilepaths(\n paths: string[],\n errorMessage: string = ''\n): string[] {\n const resolvedPaths: string[] = [];\n for (const possiblePath of paths) {\n if (fs.existsSync(possiblePath)) {\n resolvedPaths.push(possiblePath);\n }\n }\n if (errorMessage) {\n logger.error(errorMessage);\n exitSync(1);\n }\n return resolvedPaths;\n}\n\nexport function getRelativePath(file: string, srcDirectory: string): string {\n // Create relative path from src directory and remove extension\n return path\n .relative(\n srcDirectory,\n file.replace(/\\.[^/.]+$/, '') // Remove file extension\n )\n .replace(/\\\\/g, '.') // Replace Windows backslashes with dots\n .split(/[./]/) // Split on dots or forward slashes\n .filter(Boolean) // Remove empty segments that might cause extra dots\n .map((segment) => segment.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()) // Convert each segment to snake case\n .join('.'); // Rejoin with dots\n}\n\n/**\n * Find a file in a directory based on a wildcard pattern.\n * @param {string} filePattern - The wildcard pattern to search for.\n * @param {string} file - The file to search for.\n * @returns {string} - The path to the file.\n */\nexport function findFile(filePattern: string, file: string): string {\n // Handle wildcard pattern by replacing the wildcard with the file parameter\n const resolvedPath = filePattern.replace(/\\*/, file);\n\n if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {\n return fs.readFileSync(resolvedPath, 'utf8');\n }\n return '';\n}\n\n/**\n * Read a file and return the contents.\n * @param {string} filePath - The path to the file to read.\n * @returns {string} - The contents of the file.\n */\nexport function readFile(filePath: string): string {\n if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {\n return fs.readFileSync(filePath, 'utf8');\n }\n return '';\n}\n\n/**\n * Find a file in a directory.\n * @param {string} dir - The directory to search in.\n * @param {string} file - The file to search for.\n * @returns {string} - The path to the file.\n */\nexport function findFileInDir(dir: string, file: string): string {\n const resolvedPath = path.join(dir, file);\n try {\n if (fs.existsSync(resolvedPath)) {\n return fs.readFileSync(resolvedPath, 'utf8');\n }\n } catch (error) {\n logger.error('Error finding file in directory: ' + String(error));\n }\n return '';\n}\n\nexport function getRelative(absolutePath: string): string {\n const path2 = path.resolve(absolutePath);\n return path.relative(process.cwd(), path2);\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAwB,aACtB,OACA,eAAuB,IACf;AACR,QAAO,cAAc,OAAO,aAAa,GAAG,MAAM;;;;;;;;AASpD,SAAgB,cACd,OACA,eAAuB,IACb;CACV,MAAM,gBAA0B,EAAE;AAClC,MAAK,MAAM,gBAAgB,MACzB,KAAI,GAAG,WAAW,aAAa,CAC7B,eAAc,KAAK,aAAa;AAGpC,KAAI,cAAc;AAChB,SAAO,MAAM,aAAa;AAC1B,WAAS,EAAE;;AAEb,QAAO;;AAGT,SAAgB,gBAAgB,MAAc,cAA8B;AAE1E,QAAO,KACJ,SACC,cACA,KAAK,QAAQ,aAAa,GAAG,CAC9B,CACA,QAAQ,OAAO,IAAI,CACnB,MAAM,OAAO,CACb,OAAO,QAAQ,CACf,KAAK,YAAY,QAAQ,QAAQ,iBAAiB,IAAI,CAAC,aAAa,CAAC,CACrE,KAAK,IAAI;;;;;;;;AASd,SAAgB,SAAS,aAAqB,MAAsB;CAElE,MAAM,eAAe,YAAY,QAAQ,MAAM,KAAK;AAEpD,KAAI,GAAG,WAAW,aAAa,IAAI,GAAG,SAAS,aAAa,CAAC,QAAQ,CACnE,QAAO,GAAG,aAAa,cAAc,OAAO;AAE9C,QAAO;;;;;;;AAQT,SAAgB,SAAS,UAA0B;AACjD,KAAI,GAAG,WAAW,SAAS,IAAI,GAAG,SAAS,SAAS,CAAC,QAAQ,CAC3D,QAAO,GAAG,aAAa,UAAU,OAAO;AAE1C,QAAO;;;;;;;;AAST,SAAgB,cAAc,KAAa,MAAsB;CAC/D,MAAM,eAAe,KAAK,KAAK,KAAK,KAAK;AACzC,KAAI;AACF,MAAI,GAAG,WAAW,aAAa,CAC7B,QAAO,GAAG,aAAa,cAAc,OAAO;UAEvC,OAAO;AACd,SAAO,MAAM,sCAAsC,OAAO,MAAM,CAAC;;AAEnE,QAAO;;AAGT,SAAgB,YAAY,cAA8B;CACxD,MAAM,QAAQ,KAAK,QAAQ,aAAa;AACxC,QAAO,KAAK,SAAS,QAAQ,KAAK,EAAE,MAAM"}
|
|
1
|
+
{"version":3,"file":"findFilepath.js","names":[],"sources":["../../src/fs/findFilepath.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../console/logger.js';\nimport { exitSync } from '../console/logging.js';\n\n/**\n * Resolve the file path from the given file path or default paths.\n * @param {string} filePath - The file path to resolve.\n * @param {string[]} defaultPaths - The default paths to check.\n * @returns {string} - The resolved file path.\n */\nexport default function findFilepath(\n paths: string[],\n errorMessage: string = ''\n): string {\n return findFilepaths(paths, errorMessage)?.[0] || '';\n}\n\n/**\n * Resolve the file paths from the given file paths or default paths.\n * @param {string[]} paths - The file paths to resolve.\n * @param {string} errorMessage - The error message to throw if no paths are found.\n * @returns {string[]} - The resolved file paths.\n */\nexport function findFilepaths(\n paths: string[],\n errorMessage: string = ''\n): string[] {\n const resolvedPaths: string[] = [];\n for (const possiblePath of paths) {\n if (fs.existsSync(possiblePath)) {\n resolvedPaths.push(possiblePath);\n }\n }\n if (errorMessage) {\n logger.error(errorMessage);\n exitSync(1);\n }\n return resolvedPaths;\n}\n\nexport function getRelativePath(file: string, srcDirectory: string): string {\n // Create relative path from src directory and remove extension\n return path\n .relative(\n srcDirectory,\n file.replace(/\\.[^/.]+$/, '') // Remove file extension\n )\n .replace(/\\\\/g, '.') // Replace Windows backslashes with dots\n .split(/[./]/) // Split on dots or forward slashes\n .filter(Boolean) // Remove empty segments that might cause extra dots\n .map((segment) => segment.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()) // Convert each segment to snake case\n .join('.'); // Rejoin with dots\n}\n\n/**\n * Find a file in a directory based on a wildcard pattern.\n * @param {string} filePattern - The wildcard pattern to search for.\n * @param {string} file - The file to search for.\n * @returns {string} - The path to the file.\n */\nexport function findFile(filePattern: string, file: string): string {\n // Handle wildcard pattern by replacing the wildcard with the file parameter\n const resolvedPath = filePattern.replace(/\\*/, file);\n\n if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {\n return fs.readFileSync(resolvedPath, 'utf8');\n }\n return '';\n}\n\n/**\n * Read a file and return the contents.\n * @param {string} filePath - The path to the file to read.\n * @returns {string} - The contents of the file.\n */\nexport function readFile(filePath: string): string {\n if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {\n return fs.readFileSync(filePath, 'utf8');\n }\n return '';\n}\n\n/**\n * Read a file as raw bytes and return it base64-encoded. Used for binary\n * formats (e.g. Lottie zip bundles) whose content must not be decoded as UTF-8.\n * @param {string} filePath - The path to the file to read.\n * @returns {string} - The base64-encoded contents, or '' if the file is absent.\n */\nexport function readBinaryFileBase64(filePath: string): string {\n if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {\n return fs.readFileSync(filePath).toString('base64');\n }\n return '';\n}\n\n/**\n * Find a file in a directory.\n * @param {string} dir - The directory to search in.\n * @param {string} file - The file to search for.\n * @returns {string} - The path to the file.\n */\nexport function findFileInDir(dir: string, file: string): string {\n const resolvedPath = path.join(dir, file);\n try {\n if (fs.existsSync(resolvedPath)) {\n return fs.readFileSync(resolvedPath, 'utf8');\n }\n } catch (error) {\n logger.error('Error finding file in directory: ' + String(error));\n }\n return '';\n}\n\nexport function getRelative(absolutePath: string): string {\n const path2 = path.resolve(absolutePath);\n return path.relative(process.cwd(), path2);\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAwB,aACtB,OACA,eAAuB,IACf;AACR,QAAO,cAAc,OAAO,aAAa,GAAG,MAAM;;;;;;;;AASpD,SAAgB,cACd,OACA,eAAuB,IACb;CACV,MAAM,gBAA0B,EAAE;AAClC,MAAK,MAAM,gBAAgB,MACzB,KAAI,GAAG,WAAW,aAAa,CAC7B,eAAc,KAAK,aAAa;AAGpC,KAAI,cAAc;AAChB,SAAO,MAAM,aAAa;AAC1B,WAAS,EAAE;;AAEb,QAAO;;AAGT,SAAgB,gBAAgB,MAAc,cAA8B;AAE1E,QAAO,KACJ,SACC,cACA,KAAK,QAAQ,aAAa,GAAG,CAC9B,CACA,QAAQ,OAAO,IAAI,CACnB,MAAM,OAAO,CACb,OAAO,QAAQ,CACf,KAAK,YAAY,QAAQ,QAAQ,iBAAiB,IAAI,CAAC,aAAa,CAAC,CACrE,KAAK,IAAI;;;;;;;;AASd,SAAgB,SAAS,aAAqB,MAAsB;CAElE,MAAM,eAAe,YAAY,QAAQ,MAAM,KAAK;AAEpD,KAAI,GAAG,WAAW,aAAa,IAAI,GAAG,SAAS,aAAa,CAAC,QAAQ,CACnE,QAAO,GAAG,aAAa,cAAc,OAAO;AAE9C,QAAO;;;;;;;AAQT,SAAgB,SAAS,UAA0B;AACjD,KAAI,GAAG,WAAW,SAAS,IAAI,GAAG,SAAS,SAAS,CAAC,QAAQ,CAC3D,QAAO,GAAG,aAAa,UAAU,OAAO;AAE1C,QAAO;;;;;;;;AAST,SAAgB,qBAAqB,UAA0B;AAC7D,KAAI,GAAG,WAAW,SAAS,IAAI,GAAG,SAAS,SAAS,CAAC,QAAQ,CAC3D,QAAO,GAAG,aAAa,SAAS,CAAC,SAAS,SAAS;AAErD,QAAO;;;;;;;;AAST,SAAgB,cAAc,KAAa,MAAsB;CAC/D,MAAM,eAAe,KAAK,KAAK,KAAK,KAAK;AACzC,KAAI;AACF,MAAI,GAAG,WAAW,aAAa,CAC7B,QAAO,GAAG,aAAa,cAAc,OAAO;UAEvC,OAAO;AACd,SAAO,MAAM,sCAAsC,OAAO,MAAM,CAAC;;AAEnE,QAAO;;AAGT,SAAgB,YAAY,cAA8B;CACxD,MAAM,QAAQ,KAAK,QAAQ,aAAa;AACxC,QAAO,KAAK,SAAS,QAAQ,KAAK,EAAE,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "2.
|
|
1
|
+
export declare const PACKAGE_VERSION = "2.16.1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.16.1';\n"],"mappings":";AACA,MAAa,kBAAkB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -169,6 +169,10 @@ export type FilesOptions = {
|
|
|
169
169
|
includeSourceCodeContext?: boolean;
|
|
170
170
|
};
|
|
171
171
|
};
|
|
172
|
+
export type FontsConfig = {
|
|
173
|
+
include: string[];
|
|
174
|
+
exclude?: string[];
|
|
175
|
+
};
|
|
172
176
|
export type Settings = {
|
|
173
177
|
config: string;
|
|
174
178
|
configDirectory: string;
|
|
@@ -207,6 +211,7 @@ export type Settings = {
|
|
|
207
211
|
version?: string;
|
|
208
212
|
description?: string;
|
|
209
213
|
src?: string[];
|
|
214
|
+
fonts?: FontsConfig;
|
|
210
215
|
framework?: SupportedFrameworks;
|
|
211
216
|
options?: AdditionalOptions;
|
|
212
217
|
modelProvider?: string;
|
|
@@ -2,6 +2,7 @@ import { logger } from "../console/logger.js";
|
|
|
2
2
|
import { gt } from "../utils/gt.js";
|
|
3
3
|
import { logCollectedFiles, logErrorAndExit } from "../console/logging.js";
|
|
4
4
|
import { branchResolutionError, withOriginalError } from "../console/index.js";
|
|
5
|
+
import { syncFonts } from "./utils/syncFonts.js";
|
|
5
6
|
import { BranchStep } from "./steps/BranchStep.js";
|
|
6
7
|
import { EnqueueStep } from "./steps/EnqueueStep.js";
|
|
7
8
|
import { filterFilesForEnqueue } from "./utils/filterFilesForEnqueue.js";
|
|
@@ -20,6 +21,7 @@ async function runEnqueueWorkflow({ files, options, settings }) {
|
|
|
20
21
|
try {
|
|
21
22
|
logCollectedFiles(files);
|
|
22
23
|
logger.debug("Files: " + JSON.stringify(files, null, 2));
|
|
24
|
+
await syncFonts(settings);
|
|
23
25
|
const branchStep = new BranchStep(gt, settings);
|
|
24
26
|
const enqueueStep = new EnqueueStep(gt, settings, options.force);
|
|
25
27
|
const branchData = await branchStep.run();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enqueue.js","names":[],"sources":["../../src/workflows/enqueue.ts"],"sourcesContent":["import { logCollectedFiles, logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { EnqueueFilesResult, FileToUpload } from 'generaltranslation/types';\nimport { EnqueueStep } from './steps/EnqueueStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { logger } from '../console/logger.js';\nimport { filterFilesForEnqueue } from './utils/filterFilesForEnqueue.js';\n\n/**\n * Enqueues translations for a given set of files\n * - Only enqueues uploaded files\n * - Don't have to worry about double enqueuing files because dedupe on API side\n *\n * @param {FileTranslationData} fileVersionData - The file version data\n * @param {TranslateFlags} options - The options for the enqueue operation\n * @param {Settings} settings - The settings for the enqueue operation\n * @returns {Promise<EnqueueFilesResult>} The enqueue result\n */\nexport async function runEnqueueWorkflow({\n files,\n options,\n settings,\n}: {\n files: FileToUpload[];\n options: TranslateFlags;\n settings: Settings;\n}): Promise<EnqueueFilesResult> {\n try {\n // Log files to be enqueued\n logCollectedFiles(files);\n\n logger.debug('Files: ' + JSON.stringify(files, null, 2));\n\n // Create workflow with steps\n const branchStep = new BranchStep(gt, settings);\n // const queryFileDataStep = new QueryFileDataStep(gt);\n const enqueueStep = new EnqueueStep(gt, settings, options.force);\n\n // (1) run the branch step\n const branchData = await branchStep.run();\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n logger.debug('Branch data: ' + JSON.stringify(branchData, null, 2));\n\n // (2) Enqueue the files\n const filesWithBranch = files.map((files) => ({\n branchId: branchData.currentBranch.id,\n ...files,\n }));\n const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({\n gt,\n files: filesWithBranch,\n locales: settings.locales,\n force: options.force,\n });\n if (skippedFiles.length > 0) {\n logger.info(\n `Skipped enqueue for ${skippedFiles.length} already translated file${skippedFiles.length === 1 ? '' : 's'}`\n );\n }\n\n const enqueueResult = await enqueueStep.run(filesToEnqueue);\n\n logger.debug('Enqueue result: ' + JSON.stringify(enqueueResult, null, 2));\n\n logEnqueueResult(\n enqueueResult,\n filesToEnqueue.length === 0 ? files.length : filesToEnqueue.length\n );\n return enqueueResult;\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Translations could not be enqueued. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n\n// ----- Helper functions ----- //\n\n/**\n * Logs the enqueue result\n * @param enqueueResult - The enqueue result\n * @returns void\n */\nfunction logEnqueueResult(\n enqueueResult: EnqueueFilesResult,\n fileCount: number\n): void {\n if (Object.keys(enqueueResult.jobData).length === 0) {\n logger.success(\n `All ${fileCount} ${fileCount === 1 ? 'file' : 'files'} already translated. 0 files enqueued.`\n );\n } else {\n logger.success(enqueueResult.message);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"enqueue.js","names":[],"sources":["../../src/workflows/enqueue.ts"],"sourcesContent":["import { logCollectedFiles, logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { EnqueueFilesResult, FileToUpload } from 'generaltranslation/types';\nimport { EnqueueStep } from './steps/EnqueueStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { logger } from '../console/logger.js';\nimport { filterFilesForEnqueue } from './utils/filterFilesForEnqueue.js';\nimport { syncFonts } from './utils/syncFonts.js';\n\n/**\n * Enqueues translations for a given set of files\n * - Only enqueues uploaded files\n * - Don't have to worry about double enqueuing files because dedupe on API side\n *\n * @param {FileTranslationData} fileVersionData - The file version data\n * @param {TranslateFlags} options - The options for the enqueue operation\n * @param {Settings} settings - The settings for the enqueue operation\n * @returns {Promise<EnqueueFilesResult>} The enqueue result\n */\nexport async function runEnqueueWorkflow({\n files,\n options,\n settings,\n}: {\n files: FileToUpload[];\n options: TranslateFlags;\n settings: Settings;\n}): Promise<EnqueueFilesResult> {\n try {\n // Log files to be enqueued\n logCollectedFiles(files);\n\n logger.debug('Files: ' + JSON.stringify(files, null, 2));\n\n // Sync fonts before enqueueing so the translation jobs (e.g. Lottie\n // layout refinement) can use them instead of fallback fonts.\n await syncFonts(settings);\n\n // Create workflow with steps\n const branchStep = new BranchStep(gt, settings);\n // const queryFileDataStep = new QueryFileDataStep(gt);\n const enqueueStep = new EnqueueStep(gt, settings, options.force);\n\n // (1) run the branch step\n const branchData = await branchStep.run();\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n logger.debug('Branch data: ' + JSON.stringify(branchData, null, 2));\n\n // (2) Enqueue the files\n const filesWithBranch = files.map((files) => ({\n branchId: branchData.currentBranch.id,\n ...files,\n }));\n const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({\n gt,\n files: filesWithBranch,\n locales: settings.locales,\n force: options.force,\n });\n if (skippedFiles.length > 0) {\n logger.info(\n `Skipped enqueue for ${skippedFiles.length} already translated file${skippedFiles.length === 1 ? '' : 's'}`\n );\n }\n\n const enqueueResult = await enqueueStep.run(filesToEnqueue);\n\n logger.debug('Enqueue result: ' + JSON.stringify(enqueueResult, null, 2));\n\n logEnqueueResult(\n enqueueResult,\n filesToEnqueue.length === 0 ? files.length : filesToEnqueue.length\n );\n return enqueueResult;\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Translations could not be enqueued. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n\n// ----- Helper functions ----- //\n\n/**\n * Logs the enqueue result\n * @param enqueueResult - The enqueue result\n * @returns void\n */\nfunction logEnqueueResult(\n enqueueResult: EnqueueFilesResult,\n fileCount: number\n): void {\n if (Object.keys(enqueueResult.jobData).length === 0) {\n logger.success(\n `All ${fileCount} ${fileCount === 1 ? 'file' : 'files'} already translated. 0 files enqueued.`\n );\n } else {\n logger.success(enqueueResult.message);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,eAAsB,mBAAmB,EACvC,OACA,SACA,YAK8B;AAC9B,KAAI;AAEF,oBAAkB,MAAM;AAExB,SAAO,MAAM,YAAY,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;AAIxD,QAAM,UAAU,SAAS;EAGzB,MAAM,aAAa,IAAI,WAAW,IAAI,SAAS;EAE/C,MAAM,cAAc,IAAI,YAAY,IAAI,UAAU,QAAQ,MAAM;EAGhE,MAAM,aAAa,MAAM,WAAW,KAAK;AACzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;AAE/C,SAAO,MAAM,kBAAkB,KAAK,UAAU,YAAY,MAAM,EAAE,CAAC;EAOnE,MAAM,EAAE,gBAAgB,iBAAiB,MAAM,sBAAsB;GACnE;GACA,OANsB,MAAM,KAAK,WAAW;IAC5C,UAAU,WAAW,cAAc;IACnC,GAAG;IACJ,EAGuB;GACtB,SAAS,SAAS;GAClB,OAAO,QAAQ;GAChB,CAAC;AACF,MAAI,aAAa,SAAS,EACxB,QAAO,KACL,uBAAuB,aAAa,OAAO,0BAA0B,aAAa,WAAW,IAAI,KAAK,MACvG;EAGH,MAAM,gBAAgB,MAAM,YAAY,IAAI,eAAe;AAE3D,SAAO,MAAM,qBAAqB,KAAK,UAAU,eAAe,MAAM,EAAE,CAAC;AAEzE,mBACE,eACA,eAAe,WAAW,IAAI,MAAM,SAAS,eAAe,OAC7D;AACD,SAAO;UACA,OAAO;AACd,SAAO,gBACL,kBACE,mHACA,MACD,CACF;;;;;;;;AAWL,SAAS,iBACP,eACA,WACM;AACN,KAAI,OAAO,KAAK,cAAc,QAAQ,CAAC,WAAW,EAChD,QAAO,QACL,OAAO,UAAU,GAAG,cAAc,IAAI,SAAS,QAAQ,wCACxD;KAED,QAAO,QAAQ,cAAc,QAAQ"}
|
package/dist/workflows/stage.js
CHANGED
|
@@ -2,6 +2,7 @@ import { logger } from "../console/logger.js";
|
|
|
2
2
|
import { gt } from "../utils/gt.js";
|
|
3
3
|
import { logCollectedFiles, logErrorAndExit } from "../console/logging.js";
|
|
4
4
|
import { branchResolutionError, withOriginalError } from "../console/index.js";
|
|
5
|
+
import { syncFonts } from "./utils/syncFonts.js";
|
|
5
6
|
import { BranchStep } from "./steps/BranchStep.js";
|
|
6
7
|
import { UploadSourcesStep } from "./steps/UploadSourcesStep.js";
|
|
7
8
|
import { SetupStep } from "./steps/SetupStep.js";
|
|
@@ -21,6 +22,7 @@ import { filterFilesForEnqueue } from "./utils/filterFilesForEnqueue.js";
|
|
|
21
22
|
async function runStageFilesWorkflow({ files, options, settings }) {
|
|
22
23
|
try {
|
|
23
24
|
logCollectedFiles(files);
|
|
25
|
+
await syncFonts(settings);
|
|
24
26
|
const timeoutMs = calculateTimeoutMs(options.timeout);
|
|
25
27
|
const branchStep = new BranchStep(gt, settings);
|
|
26
28
|
const uploadStep = new UploadSourcesStep(gt, settings);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage.js","names":[],"sources":["../../src/workflows/stage.ts"],"sourcesContent":["import { logCollectedFiles, logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { logger } from '../console/logger.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { EnqueueFilesResult, FileToUpload } from 'generaltranslation/types';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { SetupStep } from './steps/SetupStep.js';\nimport { EnqueueStep } from './steps/EnqueueStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { TagStep } from './steps/TagStep.js';\nimport { UserEditDiffsStep } from './steps/UserEditDiffsStep.js';\nimport { BranchData } from '../types/branch.js';\nimport { calculateTimeoutMs } from '../utils/calculateTimeoutMs.js';\nimport { filterFilesForEnqueue } from './utils/filterFilesForEnqueue.js';\n\n/**\n * Sends multiple files for translation to the API using a workflow pattern\n * @param files - Array of file objects to translate\n * @param options - The options for the API call\n * @param settings - Settings configuration\n * @returns The translated content or version ID\n */\nexport async function runStageFilesWorkflow({\n files,\n options,\n settings,\n}: {\n files: FileToUpload[];\n options: TranslateFlags;\n settings: Settings;\n}): Promise<{\n branchData: BranchData;\n enqueueResult: EnqueueFilesResult;\n}> {\n try {\n // Log files to be translated\n logCollectedFiles(files);\n\n // Calculate timeout for setup step\n const timeoutMs = calculateTimeoutMs(options.timeout);\n\n // Create workflow with steps\n const branchStep = new BranchStep(gt, settings);\n const uploadStep = new UploadSourcesStep(gt, settings);\n const userEditDiffsStep = new UserEditDiffsStep(settings);\n const setupStep = new SetupStep(gt, settings, timeoutMs);\n const enqueueStep = new EnqueueStep(gt, settings, options.force);\n\n // first run the branch step\n const branchData = await branchStep.run();\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n // then run the upload step\n const uploadedFiles = await uploadStep.run({ files, branchData });\n\n // optionally run the user edit diffs step\n if (options?.saveLocal) {\n await userEditDiffsStep.run(uploadedFiles);\n }\n\n // then run the tag step (non-fatal — tagging failure should not block translations)\n if (settings.tag) {\n try {\n const userProvidedTag = !!options.tag;\n const tagStep = new TagStep(gt, settings, userProvidedTag);\n await tagStep.run(uploadedFiles);\n } catch {\n logger.warn('Failed to create translation tag. Continuing...');\n }\n }\n\n // then run the setup step\n await setupStep.run(uploadedFiles);\n\n // then run the enqueue step\n const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({\n gt,\n files: uploadedFiles,\n locales: settings.locales,\n force: options.force,\n });\n if (skippedFiles.length > 0) {\n logger.info(\n `Skipped enqueue for ${skippedFiles.length} already translated file${skippedFiles.length === 1 ? '' : 's'}`\n );\n }\n\n const enqueueResult = await enqueueStep.run(filesToEnqueue);\n\n return { branchData, enqueueResult };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Files could not be sent for translation. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"stage.js","names":[],"sources":["../../src/workflows/stage.ts"],"sourcesContent":["import { logCollectedFiles, logErrorAndExit } from '../console/logging.js';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { logger } from '../console/logger.js';\nimport { Settings, TranslateFlags } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { EnqueueFilesResult, FileToUpload } from 'generaltranslation/types';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { SetupStep } from './steps/SetupStep.js';\nimport { EnqueueStep } from './steps/EnqueueStep.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { TagStep } from './steps/TagStep.js';\nimport { UserEditDiffsStep } from './steps/UserEditDiffsStep.js';\nimport { BranchData } from '../types/branch.js';\nimport { calculateTimeoutMs } from '../utils/calculateTimeoutMs.js';\nimport { filterFilesForEnqueue } from './utils/filterFilesForEnqueue.js';\nimport { syncFonts } from './utils/syncFonts.js';\n\n/**\n * Sends multiple files for translation to the API using a workflow pattern\n * @param files - Array of file objects to translate\n * @param options - The options for the API call\n * @param settings - Settings configuration\n * @returns The translated content or version ID\n */\nexport async function runStageFilesWorkflow({\n files,\n options,\n settings,\n}: {\n files: FileToUpload[];\n options: TranslateFlags;\n settings: Settings;\n}): Promise<{\n branchData: BranchData;\n enqueueResult: EnqueueFilesResult;\n}> {\n try {\n // Log files to be translated\n logCollectedFiles(files);\n\n // Sync fonts before enqueueing so the translation jobs (e.g. Lottie\n // layout refinement) can use them instead of fallback fonts.\n await syncFonts(settings);\n\n // Calculate timeout for setup step\n const timeoutMs = calculateTimeoutMs(options.timeout);\n\n // Create workflow with steps\n const branchStep = new BranchStep(gt, settings);\n const uploadStep = new UploadSourcesStep(gt, settings);\n const userEditDiffsStep = new UserEditDiffsStep(settings);\n const setupStep = new SetupStep(gt, settings, timeoutMs);\n const enqueueStep = new EnqueueStep(gt, settings, options.force);\n\n // first run the branch step\n const branchData = await branchStep.run();\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n // then run the upload step\n const uploadedFiles = await uploadStep.run({ files, branchData });\n\n // optionally run the user edit diffs step\n if (options?.saveLocal) {\n await userEditDiffsStep.run(uploadedFiles);\n }\n\n // then run the tag step (non-fatal — tagging failure should not block translations)\n if (settings.tag) {\n try {\n const userProvidedTag = !!options.tag;\n const tagStep = new TagStep(gt, settings, userProvidedTag);\n await tagStep.run(uploadedFiles);\n } catch {\n logger.warn('Failed to create translation tag. Continuing...');\n }\n }\n\n // then run the setup step\n await setupStep.run(uploadedFiles);\n\n // then run the enqueue step\n const { filesToEnqueue, skippedFiles } = await filterFilesForEnqueue({\n gt,\n files: uploadedFiles,\n locales: settings.locales,\n force: options.force,\n });\n if (skippedFiles.length > 0) {\n logger.info(\n `Skipped enqueue for ${skippedFiles.length} already translated file${skippedFiles.length === 1 ? '' : 's'}`\n );\n }\n\n const enqueueResult = await enqueueStep.run(filesToEnqueue);\n\n return { branchData, enqueueResult };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Files could not be sent for translation. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwBA,eAAsB,sBAAsB,EAC1C,OACA,SACA,YAQC;AACD,KAAI;AAEF,oBAAkB,MAAM;AAIxB,QAAM,UAAU,SAAS;EAGzB,MAAM,YAAY,mBAAmB,QAAQ,QAAQ;EAGrD,MAAM,aAAa,IAAI,WAAW,IAAI,SAAS;EAC/C,MAAM,aAAa,IAAI,kBAAkB,IAAI,SAAS;EACtD,MAAM,oBAAoB,IAAI,kBAAkB,SAAS;EACzD,MAAM,YAAY,IAAI,UAAU,IAAI,UAAU,UAAU;EACxD,MAAM,cAAc,IAAI,YAAY,IAAI,UAAU,QAAQ,MAAM;EAGhE,MAAM,aAAa,MAAM,WAAW,KAAK;AACzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;EAI/C,MAAM,gBAAgB,MAAM,WAAW,IAAI;GAAE;GAAO;GAAY,CAAC;AAGjE,MAAI,SAAS,UACX,OAAM,kBAAkB,IAAI,cAAc;AAI5C,MAAI,SAAS,IACX,KAAI;AAGF,SAAM,IADc,QAAQ,IAAI,UAAU,CADjB,CAAC,QAAQ,IAErB,CAAC,IAAI,cAAc;UAC1B;AACN,UAAO,KAAK,kDAAkD;;AAKlE,QAAM,UAAU,IAAI,cAAc;EAGlC,MAAM,EAAE,gBAAgB,iBAAiB,MAAM,sBAAsB;GACnE;GACA,OAAO;GACP,SAAS,SAAS;GAClB,OAAO,QAAQ;GAChB,CAAC;AACF,MAAI,aAAa,SAAS,EACxB,QAAO,KACL,uBAAuB,aAAa,OAAO,0BAA0B,aAAa,WAAW,IAAI,KAAK,MACvG;AAKH,SAAO;GAAE;GAAY,eAAA,MAFO,YAAY,IAAI,eAAe;GAEvB;UAC7B,OAAO;AACd,SAAO,gBACL,kBACE,wHACA,MACD,CACF"}
|
package/dist/workflows/upload.js
CHANGED
|
@@ -2,6 +2,7 @@ import { logger } from "../console/logger.js";
|
|
|
2
2
|
import { gt } from "../utils/gt.js";
|
|
3
3
|
import { logErrorAndExit } from "../console/logging.js";
|
|
4
4
|
import { branchResolutionError, withOriginalError } from "../console/index.js";
|
|
5
|
+
import { syncFonts } from "./utils/syncFonts.js";
|
|
5
6
|
import { BranchStep } from "./steps/BranchStep.js";
|
|
6
7
|
import { UploadSourcesStep } from "./steps/UploadSourcesStep.js";
|
|
7
8
|
import { UploadTranslationsStep } from "./steps/UploadTranslationsStep.js";
|
|
@@ -16,6 +17,7 @@ import chalk from "chalk";
|
|
|
16
17
|
async function runUploadFilesWorkflow({ files, options }) {
|
|
17
18
|
try {
|
|
18
19
|
logger.message(chalk.cyan("Files to upload:") + "\n" + files.map((file) => ` - ${chalk.bold(file.source.fileName)}${file.translations.length > 0 ? ` -> ${file.translations.map((t) => t.locale).join(", ")}` : ""}`).join("\n"));
|
|
20
|
+
await syncFonts(options);
|
|
19
21
|
const branchStep = new BranchStep(gt, options);
|
|
20
22
|
const uploadStep = new UploadSourcesStep(gt, options);
|
|
21
23
|
const uploadTranslationsStep = new UploadTranslationsStep(gt, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","names":[],"sources":["../../src/workflows/upload.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { logger } from '../console/logger.js';\nimport { logErrorAndExit } from '../console/logging.js';\nimport { Settings } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { UploadTranslationsStep } from './steps/UploadTranslationsStep.js';\nimport type { FileToUpload } from 'generaltranslation/types';\nimport { BranchData } from '../types/branch.js';\n\n/**\n * Uploads multiple files to the API using a workflow pattern\n * @param files - Array of file objects to upload\n * @param options - The options for the API call\n * @returns The branch data resolved during the workflow\n */\nexport async function runUploadFilesWorkflow({\n files,\n options,\n}: {\n files: {\n source: FileToUpload;\n translations: FileToUpload[];\n }[];\n options: Settings;\n}): Promise<{ branchData: BranchData }> {\n try {\n logger.message(\n chalk.cyan('Files to upload:') +\n '\\n' +\n files\n .map(\n (file) =>\n ` - ${chalk.bold(file.source.fileName)}${file.translations.length > 0 ? ` -> ${file.translations.map((t) => t.locale).join(', ')}` : ''}`\n )\n .join('\\n')\n );\n\n // Create workflow steps\n const branchStep = new BranchStep(gt, options);\n const uploadStep = new UploadSourcesStep(gt, options);\n const uploadTranslationsStep = new UploadTranslationsStep(gt, options);\n\n // Step 1: Resolve branch information\n const branchData = await branchStep.run();\n\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n await uploadStep.run({ files: files.map((f) => f.source), branchData });\n\n // Step 3: Upload translations (if any exist)\n const filesWithTranslations = files.filter(\n (f) => f.translations.length > 0\n );\n if (filesWithTranslations.length > 0) {\n await uploadTranslationsStep.run({\n files: filesWithTranslations,\n });\n }\n\n logger.success('All files uploaded successfully');\n return { branchData };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Files could not be uploaded. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload.js","names":[],"sources":["../../src/workflows/upload.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { branchResolutionError, withOriginalError } from '../console/index.js';\nimport { logger } from '../console/logger.js';\nimport { logErrorAndExit } from '../console/logging.js';\nimport { Settings } from '../types/index.js';\nimport { gt } from '../utils/gt.js';\nimport { syncFonts } from './utils/syncFonts.js';\nimport { BranchStep } from './steps/BranchStep.js';\nimport { UploadSourcesStep } from './steps/UploadSourcesStep.js';\nimport { UploadTranslationsStep } from './steps/UploadTranslationsStep.js';\nimport type { FileToUpload } from 'generaltranslation/types';\nimport { BranchData } from '../types/branch.js';\n\n/**\n * Uploads multiple files to the API using a workflow pattern\n * @param files - Array of file objects to upload\n * @param options - The options for the API call\n * @returns The branch data resolved during the workflow\n */\nexport async function runUploadFilesWorkflow({\n files,\n options,\n}: {\n files: {\n source: FileToUpload;\n translations: FileToUpload[];\n }[];\n options: Settings;\n}): Promise<{ branchData: BranchData }> {\n try {\n logger.message(\n chalk.cyan('Files to upload:') +\n '\\n' +\n files\n .map(\n (file) =>\n ` - ${chalk.bold(file.source.fileName)}${file.translations.length > 0 ? ` -> ${file.translations.map((t) => t.locale).join(', ')}` : ''}`\n )\n .join('\\n')\n );\n\n // Sync fonts first (locale-invariant) so they're available when\n // translating formats that need them.\n await syncFonts(options);\n\n // Create workflow steps\n const branchStep = new BranchStep(gt, options);\n const uploadStep = new UploadSourcesStep(gt, options);\n const uploadTranslationsStep = new UploadTranslationsStep(gt, options);\n\n // Step 1: Resolve branch information\n const branchData = await branchStep.run();\n\n if (!branchData) {\n return logErrorAndExit(branchResolutionError);\n }\n\n await uploadStep.run({ files: files.map((f) => f.source), branchData });\n\n // Step 3: Upload translations (if any exist)\n const filesWithTranslations = files.filter(\n (f) => f.translations.length > 0\n );\n if (filesWithTranslations.length > 0) {\n await uploadTranslationsStep.run({\n files: filesWithTranslations,\n });\n }\n\n logger.success('All files uploaded successfully');\n return { branchData };\n } catch (error) {\n return logErrorAndExit(\n withOriginalError(\n 'Files could not be uploaded. Check the files, branch configuration, and API credentials, then try again.',\n error\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,eAAsB,uBAAuB,EAC3C,OACA,WAOsC;AACtC,KAAI;AACF,SAAO,QACL,MAAM,KAAK,mBAAmB,GAC5B,OACA,MACG,KACE,SACC,OAAO,MAAM,KAAK,KAAK,OAAO,SAAS,GAAG,KAAK,aAAa,SAAS,IAAI,OAAO,KAAK,aAAa,KAAK,MAAM,EAAE,OAAO,CAAC,KAAK,KAAK,KAAK,KACzI,CACA,KAAK,KAAK,CAChB;AAID,QAAM,UAAU,QAAQ;EAGxB,MAAM,aAAa,IAAI,WAAW,IAAI,QAAQ;EAC9C,MAAM,aAAa,IAAI,kBAAkB,IAAI,QAAQ;EACrD,MAAM,yBAAyB,IAAI,uBAAuB,IAAI,QAAQ;EAGtE,MAAM,aAAa,MAAM,WAAW,KAAK;AAEzC,MAAI,CAAC,WACH,QAAO,gBAAgB,sBAAsB;AAG/C,QAAM,WAAW,IAAI;GAAE,OAAO,MAAM,KAAK,MAAM,EAAE,OAAO;GAAE;GAAY,CAAC;EAGvE,MAAM,wBAAwB,MAAM,QACjC,MAAM,EAAE,aAAa,SAAS,EAChC;AACD,MAAI,sBAAsB,SAAS,EACjC,OAAM,uBAAuB,IAAI,EAC/B,OAAO,uBACR,CAAC;AAGJ,SAAO,QAAQ,kCAAkC;AACjD,SAAO,EAAE,YAAY;UACd,OAAO;AACd,SAAO,gBACL,kBACE,4GACA,MACD,CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Settings } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Syncs configured project fonts to the API so they're available when
|
|
4
|
+
* translation jobs run (e.g. Lottie layout refinement). Fonts are
|
|
5
|
+
* locale-invariant and the upload is idempotent server-side, so calling this
|
|
6
|
+
* from every workflow that triggers jobs is safe. A failure is non-fatal —
|
|
7
|
+
* translation still proceeds with fallback fonts.
|
|
8
|
+
*/
|
|
9
|
+
export declare function syncFonts(settings: Settings): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { logger } from "../../console/logger.js";
|
|
2
|
+
import { gt } from "../../utils/gt.js";
|
|
3
|
+
import { collectFonts } from "../../formats/files/collectFonts.js";
|
|
4
|
+
//#region src/workflows/utils/syncFonts.ts
|
|
5
|
+
/**
|
|
6
|
+
* Syncs configured project fonts to the API so they're available when
|
|
7
|
+
* translation jobs run (e.g. Lottie layout refinement). Fonts are
|
|
8
|
+
* locale-invariant and the upload is idempotent server-side, so calling this
|
|
9
|
+
* from every workflow that triggers jobs is safe. A failure is non-fatal —
|
|
10
|
+
* translation still proceeds with fallback fonts.
|
|
11
|
+
*/
|
|
12
|
+
async function syncFonts(settings) {
|
|
13
|
+
const fonts = await collectFonts(settings);
|
|
14
|
+
if (fonts.length === 0) return;
|
|
15
|
+
try {
|
|
16
|
+
const result = await gt.uploadFonts(fonts);
|
|
17
|
+
logger.success(`Synced ${result.count} font(s)`);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
logger.warn(`Font sync failed; continuing without provisioned fonts: ${error instanceof Error ? error.message : String(error)}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { syncFonts };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=syncFonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncFonts.js","names":[],"sources":["../../../src/workflows/utils/syncFonts.ts"],"sourcesContent":["import { logger } from '../../console/logger.js';\nimport { Settings } from '../../types/index.js';\nimport { gt } from '../../utils/gt.js';\nimport { collectFonts } from '../../formats/files/collectFonts.js';\n\n/**\n * Syncs configured project fonts to the API so they're available when\n * translation jobs run (e.g. Lottie layout refinement). Fonts are\n * locale-invariant and the upload is idempotent server-side, so calling this\n * from every workflow that triggers jobs is safe. A failure is non-fatal —\n * translation still proceeds with fallback fonts.\n */\nexport async function syncFonts(settings: Settings): Promise<void> {\n const fonts = await collectFonts(settings);\n if (fonts.length === 0) return;\n try {\n const result = await gt.uploadFonts(fonts);\n logger.success(`Synced ${result.count} font(s)`);\n } catch (error) {\n logger.warn(\n `Font sync failed; continuing without provisioned fonts: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAYA,eAAsB,UAAU,UAAmC;CACjE,MAAM,QAAQ,MAAM,aAAa,SAAS;AAC1C,KAAI,MAAM,WAAW,EAAG;AACxB,KAAI;EACF,MAAM,SAAS,MAAM,GAAG,YAAY,MAAM;AAC1C,SAAO,QAAQ,UAAU,OAAO,MAAM,UAAU;UACzC,OAAO;AACd,SAAO,KACL,2DACE,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GAEzD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "bin/main.js",
|
|
6
6
|
"files": [
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"enhanced-resolve": "^5.18.3",
|
|
93
93
|
"esbuild": "^0.27.2",
|
|
94
94
|
"fast-glob": "^3.3.3",
|
|
95
|
+
"fflate": "^0.8.2",
|
|
95
96
|
"fast-json-stable-stringify": "^2.1.0",
|
|
96
97
|
"html-entities": "^2.6.0",
|
|
97
98
|
"ink": "^5.2.1",
|
|
@@ -116,9 +117,9 @@
|
|
|
116
117
|
"yaml": "^2.8.0",
|
|
117
118
|
"@generaltranslation/icu": "0.1.1",
|
|
118
119
|
"@generaltranslation/format": "0.1.4",
|
|
119
|
-
"@generaltranslation/python-extractor": "0.2.
|
|
120
|
-
"@generaltranslation/supported-locales": "2.1.
|
|
121
|
-
"generaltranslation": "9.
|
|
120
|
+
"@generaltranslation/python-extractor": "0.2.34",
|
|
121
|
+
"@generaltranslation/supported-locales": "2.1.14",
|
|
122
|
+
"generaltranslation": "9.1.1",
|
|
122
123
|
"gt-remark": "1.0.11"
|
|
123
124
|
},
|
|
124
125
|
"devDependencies": {
|