gt 2.15.0 → 2.16.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/api/downloadFileBatch.js +28 -1
  3. package/dist/api/downloadFileBatch.js.map +1 -1
  4. package/dist/cli/base.js +2 -0
  5. package/dist/cli/base.js.map +1 -1
  6. package/dist/cli/commands/download.js +2 -1
  7. package/dist/cli/commands/download.js.map +1 -1
  8. package/dist/cli/commands/upload.js +5 -3
  9. package/dist/cli/commands/upload.js.map +1 -1
  10. package/dist/console/index.d.ts +3 -0
  11. package/dist/console/index.js +4 -1
  12. package/dist/console/index.js.map +1 -1
  13. package/dist/formats/files/aggregateFiles.js +32 -2
  14. package/dist/formats/files/aggregateFiles.js.map +1 -1
  15. package/dist/formats/files/collectFonts.d.ts +7 -0
  16. package/dist/formats/files/collectFonts.js +30 -0
  17. package/dist/formats/files/collectFonts.js.map +1 -0
  18. package/dist/formats/files/detectLottieExpressions.d.ts +8 -0
  19. package/dist/formats/files/detectLottieExpressions.js +42 -0
  20. package/dist/formats/files/detectLottieExpressions.js.map +1 -0
  21. package/dist/formats/files/supportedFiles.d.ts +2 -1
  22. package/dist/formats/files/supportedFiles.js +4 -2
  23. package/dist/formats/files/supportedFiles.js.map +1 -1
  24. package/dist/formats/files/transformFormat.d.ts +2 -0
  25. package/dist/formats/files/transformFormat.js +6 -3
  26. package/dist/formats/files/transformFormat.js.map +1 -1
  27. package/dist/fs/findFilepath.d.ts +7 -0
  28. package/dist/fs/findFilepath.js +11 -1
  29. package/dist/fs/findFilepath.js.map +1 -1
  30. package/dist/generated/version.d.ts +1 -1
  31. package/dist/generated/version.js +1 -1
  32. package/dist/generated/version.js.map +1 -1
  33. package/dist/types/index.d.ts +5 -0
  34. package/dist/workflows/enqueue.js +2 -0
  35. package/dist/workflows/enqueue.js.map +1 -1
  36. package/dist/workflows/stage.js +2 -0
  37. package/dist/workflows/stage.js.map +1 -1
  38. package/dist/workflows/upload.js +2 -0
  39. package/dist/workflows/upload.js.map +1 -1
  40. package/dist/workflows/utils/syncFonts.d.ts +9 -0
  41. package/dist/workflows/utils/syncFonts.js +25 -0
  42. package/dist/workflows/utils/syncFonts.js.map +1 -0
  43. package/package.json +5 -4
@@ -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":";;;;;;;;;;;;;;;;;;AAoBA,eAAsB,mBAAmB,EACvC,OACA,SACA,YAK8B;AAC9B,KAAI;AAEF,oBAAkB,MAAM;AAExB,SAAO,MAAM,YAAY,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;EAGxD,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"}
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"}
@@ -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":";;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,sBAAsB,EAC1C,OACA,SACA,YAQC;AACD,KAAI;AAEF,oBAAkB,MAAM;EAGxB,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"}
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"}
@@ -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":";;;;;;;;;;;;;;;AAkBA,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;EAGD,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"}
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.15.0",
3
+ "version": "2.16.0",
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",
@@ -115,10 +116,10 @@
115
116
  "unist-util-visit": "^5.0.0",
116
117
  "yaml": "^2.8.0",
117
118
  "@generaltranslation/icu": "0.1.1",
119
+ "@generaltranslation/python-extractor": "0.2.33",
118
120
  "@generaltranslation/format": "0.1.4",
119
- "@generaltranslation/python-extractor": "0.2.32",
120
- "@generaltranslation/supported-locales": "2.1.12",
121
- "generaltranslation": "9.0.5",
121
+ "@generaltranslation/supported-locales": "2.1.13",
122
+ "generaltranslation": "9.1.0",
122
123
  "gt-remark": "1.0.11"
123
124
  },
124
125
  "devDependencies": {