gtx-cli 2.5.6 → 2.5.8

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 (67) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/downloadFileBatch.js +6 -6
  3. package/dist/api/saveLocalEdits.js +4 -3
  4. package/dist/api/uploadFiles.d.ts +1 -1
  5. package/dist/api/uploadFiles.js +5 -4
  6. package/dist/cli/base.js +17 -16
  7. package/dist/cli/commands/stage.js +8 -7
  8. package/dist/cli/commands/translate.js +3 -5
  9. package/dist/cli/flags.js +2 -3
  10. package/dist/cli/react.js +16 -15
  11. package/dist/config/generateSettings.js +2 -2
  12. package/dist/config/validateSettings.d.ts +1 -1
  13. package/dist/config/validateSettings.js +4 -4
  14. package/dist/console/logger.d.ts +27 -0
  15. package/dist/console/logger.js +255 -0
  16. package/dist/console/logging.d.ts +1 -11
  17. package/dist/console/logging.js +24 -55
  18. package/dist/formats/files/save.js +2 -2
  19. package/dist/formats/files/translate.js +8 -8
  20. package/dist/formats/files/upload.js +7 -6
  21. package/dist/formats/gt/save.js +4 -3
  22. package/dist/formats/json/flattenJson.js +3 -3
  23. package/dist/formats/json/mergeJson.d.ts +1 -1
  24. package/dist/formats/json/mergeJson.js +69 -21
  25. package/dist/formats/json/parseJson.js +14 -13
  26. package/dist/formats/json/utils.js +16 -15
  27. package/dist/formats/yaml/mergeYaml.js +6 -5
  28. package/dist/formats/yaml/parseYaml.js +4 -3
  29. package/dist/formats/yaml/utils.js +4 -3
  30. package/dist/fs/clearLocaleDirs.js +6 -6
  31. package/dist/fs/config/downloadedVersions.js +3 -3
  32. package/dist/fs/config/parseFilesConfig.js +2 -2
  33. package/dist/fs/config/setupConfig.js +2 -2
  34. package/dist/fs/config/updateConfig.js +2 -2
  35. package/dist/fs/config/updateVersions.js +3 -3
  36. package/dist/fs/copyFile.js +2 -2
  37. package/dist/fs/createLoadTranslationsFile.js +3 -3
  38. package/dist/fs/determineFramework.js +3 -3
  39. package/dist/fs/findFilepath.js +5 -4
  40. package/dist/hooks/postProcess.js +9 -9
  41. package/dist/next/parse/handleInitGT.js +2 -2
  42. package/dist/react/parse/addVitePlugin/index.js +4 -3
  43. package/dist/react/parse/addVitePlugin/installCompiler.js +2 -2
  44. package/dist/react/parse/addVitePlugin/updateViteConfig.js +9 -12
  45. package/dist/react/parse/createDictionaryUpdates.js +4 -3
  46. package/dist/react/parse/createInlineUpdates.js +2 -2
  47. package/dist/setup/wizard.js +17 -16
  48. package/dist/translation/parse.js +4 -3
  49. package/dist/translation/stage.js +4 -4
  50. package/dist/translation/validate.js +6 -6
  51. package/dist/types/index.d.ts +1 -0
  52. package/dist/utils/addExplicitAnchorIds.js +2 -2
  53. package/dist/utils/credentials.js +4 -3
  54. package/dist/utils/installPackage.js +11 -11
  55. package/dist/utils/packageJson.js +4 -3
  56. package/dist/workflow/BranchStep.js +5 -4
  57. package/dist/workflow/DownloadStep.js +5 -5
  58. package/dist/workflow/EnqueueStep.js +2 -2
  59. package/dist/workflow/PollJobsStep.js +3 -3
  60. package/dist/workflow/SetupStep.js +2 -2
  61. package/dist/workflow/UploadStep.js +3 -3
  62. package/dist/workflow/UserEditDiffsStep.js +2 -2
  63. package/dist/workflow/download.js +4 -3
  64. package/dist/workflow/stage.js +5 -4
  65. package/package.json +2 -2
  66. package/dist/utils/SpinnerManager.d.ts +0 -30
  67. package/dist/utils/SpinnerManager.js +0 -73
@@ -1,6 +1,6 @@
1
1
  import chalk from 'chalk';
2
2
  import { WorkflowStep } from './Workflow.js';
3
- import { createProgressBar, logError, logWarning } from '../console/logging.js';
3
+ import { logger } from '../console/logger.js';
4
4
  import { downloadFileBatch, } from '../api/downloadFileBatch.js';
5
5
  export class DownloadTranslationsStep extends WorkflowStep {
6
6
  gt;
@@ -12,7 +12,7 @@ export class DownloadTranslationsStep extends WorkflowStep {
12
12
  this.settings = settings;
13
13
  }
14
14
  async run({ fileTracker, resolveOutputPath, forceDownload, }) {
15
- this.spinner = createProgressBar(fileTracker.completed.size);
15
+ this.spinner = logger.createProgressBar(fileTracker.completed.size);
16
16
  this.spinner.start('Downloading files...');
17
17
  // Download ready files
18
18
  const success = await this.downloadFiles(fileTracker, resolveOutputPath, forceDownload);
@@ -73,7 +73,7 @@ export class DownloadTranslationsStep extends WorkflowStep {
73
73
  const batchResult = await this.downloadFilesWithRetry(fileTracker, batchFiles, forceDownload);
74
74
  this.spinner?.stop(chalk.green(`Downloaded ${batchResult.successful.length} files${batchResult.skipped.length > 0 ? `, skipped ${batchResult.skipped.length} files` : ''}`));
75
75
  if (batchResult.failed.length > 0) {
76
- logWarning(`Failed to download ${batchResult.failed.length} files: ${batchResult.failed.map((f) => f.inputPath).join('\n')}`);
76
+ logger.warn(`Failed to download ${batchResult.failed.length} files: ${batchResult.failed.map((f) => f.inputPath).join('\n')}`);
77
77
  }
78
78
  }
79
79
  else {
@@ -83,7 +83,7 @@ export class DownloadTranslationsStep extends WorkflowStep {
83
83
  }
84
84
  catch (error) {
85
85
  this.spinner?.stop(chalk.red('An error occurred while downloading translations'));
86
- logError(chalk.red('Error: ') + error);
86
+ logger.error(chalk.red('Error: ') + error);
87
87
  return false;
88
88
  }
89
89
  }
@@ -109,7 +109,7 @@ export class DownloadTranslationsStep extends WorkflowStep {
109
109
  }
110
110
  // Calculate exponential backoff delay
111
111
  const delay = initialDelay * Math.pow(2, retryCount);
112
- logError(chalk.yellow(`Retrying ${batchResult.failed.length} failed file(s) in ${delay}ms (attempt ${retryCount + 1}/${maxRetries})...`));
112
+ logger.error(chalk.yellow(`Retrying ${batchResult.failed.length} failed file(s) in ${delay}ms (attempt ${retryCount + 1}/${maxRetries})...`));
113
113
  // Wait before retrying
114
114
  await new Promise((resolve) => setTimeout(resolve, delay));
115
115
  remainingFiles = batchResult.failed;
@@ -1,11 +1,11 @@
1
1
  import { WorkflowStep } from './Workflow.js';
2
- import { createSpinner } from '../console/logging.js';
2
+ import { logger } from '../console/logger.js';
3
3
  import chalk from 'chalk';
4
4
  export class EnqueueStep extends WorkflowStep {
5
5
  gt;
6
6
  settings;
7
7
  force;
8
- spinner = createSpinner('dots');
8
+ spinner = logger.createSpinner('dots');
9
9
  result = null;
10
10
  constructor(gt, settings, force) {
11
11
  super();
@@ -1,6 +1,6 @@
1
1
  import chalk from 'chalk';
2
2
  import { WorkflowStep } from './Workflow.js';
3
- import { createProgressBar, logError } from '../console/logging.js';
3
+ import { logger } from '../console/logger.js';
4
4
  import { TEMPLATE_FILE_NAME } from '../cli/commands/stage.js';
5
5
  export class PollTranslationJobsStep extends WorkflowStep {
6
6
  gt;
@@ -12,7 +12,7 @@ export class PollTranslationJobsStep extends WorkflowStep {
12
12
  }
13
13
  async run({ fileTracker, fileQueryData, jobData, timeoutDuration, forceRetranslation, }) {
14
14
  const startTime = Date.now();
15
- this.spinner = createProgressBar(fileQueryData.length);
15
+ this.spinner = logger.createProgressBar(fileQueryData.length);
16
16
  const spinnerMessage = forceRetranslation
17
17
  ? 'Waiting for retranslation...'
18
18
  : 'Waiting for translation...';
@@ -144,7 +144,7 @@ export class PollTranslationJobsStep extends WorkflowStep {
144
144
  }
145
145
  }
146
146
  catch (error) {
147
- logError(chalk.red('Error checking job status: ') + error);
147
+ logger.error(chalk.red('Error checking job status: ') + error);
148
148
  }
149
149
  }, 5000);
150
150
  }, msUntilNextInterval);
@@ -1,11 +1,11 @@
1
1
  import { WorkflowStep } from './Workflow.js';
2
- import { createSpinner } from '../console/logging.js';
2
+ import { logger } from '../console/logger.js';
3
3
  import chalk from 'chalk';
4
4
  export class SetupStep extends WorkflowStep {
5
5
  gt;
6
6
  settings;
7
7
  timeoutMs;
8
- spinner = createSpinner('dots');
8
+ spinner = logger.createSpinner('dots');
9
9
  setupJobId = null;
10
10
  files = null;
11
11
  completed = false;
@@ -1,10 +1,10 @@
1
1
  import { WorkflowStep } from './Workflow.js';
2
- import { createSpinner, logInfo } from '../console/logging.js';
2
+ import { logger } from '../console/logger.js';
3
3
  import chalk from 'chalk';
4
4
  export class UploadStep extends WorkflowStep {
5
5
  gt;
6
6
  settings;
7
- spinner = createSpinner('dots');
7
+ spinner = logger.createSpinner('dots');
8
8
  result = null;
9
9
  constructor(gt, settings) {
10
10
  super();
@@ -13,7 +13,7 @@ export class UploadStep extends WorkflowStep {
13
13
  }
14
14
  async run({ files, branchData, }) {
15
15
  if (files.length === 0) {
16
- logInfo('No files to upload found... skipping upload step');
16
+ logger.info('No files to upload found... skipping upload step');
17
17
  return [];
18
18
  }
19
19
  this.spinner.start(`Syncing ${files.length} file${files.length !== 1 ? 's' : ''} with General Translation API...`);
@@ -1,10 +1,10 @@
1
1
  import { WorkflowStep } from './Workflow.js';
2
- import { createSpinner } from '../console/logging.js';
2
+ import { logger } from '../console/logger.js';
3
3
  import chalk from 'chalk';
4
4
  import { collectAndSendUserEditDiffs } from '../api/collectUserEditDiffs.js';
5
5
  export class UserEditDiffsStep extends WorkflowStep {
6
6
  settings;
7
- spinner = createSpinner('dots');
7
+ spinner = logger.createSpinner('dots');
8
8
  completed = false;
9
9
  constructor(settings) {
10
10
  super();
@@ -3,7 +3,8 @@ import { gt } from '../utils/gt.js';
3
3
  import { clearLocaleDirs } from '../fs/clearLocaleDirs.js';
4
4
  import { PollTranslationJobsStep } from './PollJobsStep.js';
5
5
  import { DownloadTranslationsStep } from './DownloadStep.js';
6
- import { logError, logErrorAndExit } from '../console/logging.js';
6
+ import { logErrorAndExit } from '../console/logging.js';
7
+ import { logger } from '../console/logger.js';
7
8
  import { BranchStep } from './BranchStep.js';
8
9
  import chalk from 'chalk';
9
10
  /**
@@ -25,7 +26,7 @@ export async function downloadTranslations(fileVersionData, jobData, branchData,
25
26
  const branchResult = await branchStep.run();
26
27
  await branchStep.wait();
27
28
  if (!branchResult) {
28
- logErrorAndExit('Failed to resolve git branch information.');
29
+ return logErrorAndExit('Failed to resolve git branch information.');
29
30
  }
30
31
  branchData = branchResult;
31
32
  }
@@ -66,7 +67,7 @@ export async function downloadTranslations(fileVersionData, jobData, branchData,
66
67
  });
67
68
  await pollStep.wait();
68
69
  if (pollResult.fileTracker.failed.size > 0) {
69
- logError(`${chalk.red(`${pollResult.fileTracker.failed.size} file(s) failed to translate:`)}\n${Array.from(pollResult.fileTracker.failed.entries())
70
+ logger.error(`${chalk.red(`${pollResult.fileTracker.failed.size} file(s) failed to translate:`)}\n${Array.from(pollResult.fileTracker.failed.entries())
70
71
  .map(([key, value]) => `- ${value.fileName}`)
71
72
  .join('\n')}`);
72
73
  return false;
@@ -1,5 +1,6 @@
1
1
  import chalk from 'chalk';
2
- import { logErrorAndExit, logMessage } from '../console/logging.js';
2
+ import { logErrorAndExit } from '../console/logging.js';
3
+ import { logger } from '../console/logger.js';
3
4
  import { gt } from '../utils/gt.js';
4
5
  import { TEMPLATE_FILE_NAME } from '../cli/commands/stage.js';
5
6
  import { UploadStep } from './UploadStep.js';
@@ -18,7 +19,7 @@ function calculateTimeout(timeout) {
18
19
  * Helper: Log files to be translated
19
20
  */
20
21
  function logFilesToTranslate(files) {
21
- logMessage(chalk.cyan('Files found in project:') +
22
+ logger.message(chalk.cyan('Files found in project:') +
22
23
  '\n' +
23
24
  files
24
25
  .map((file) => {
@@ -52,7 +53,7 @@ export async function stageFiles(files, options, settings) {
52
53
  const branchData = await branchStep.run();
53
54
  await branchStep.wait();
54
55
  if (!branchData) {
55
- logErrorAndExit('Failed to resolve git branch information.');
56
+ return logErrorAndExit('Failed to resolve git branch information.');
56
57
  }
57
58
  // then run the upload step
58
59
  const uploadedFiles = await uploadStep.run({ files, branchData });
@@ -71,6 +72,6 @@ export async function stageFiles(files, options, settings) {
71
72
  return { branchData, enqueueResult };
72
73
  }
73
74
  catch (error) {
74
- logErrorAndExit('Failed to send files for translation. ' + error);
75
+ return logErrorAndExit('Failed to send files for translation. ' + error);
75
76
  }
76
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.5.6",
3
+ "version": "2.5.8",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [
@@ -76,7 +76,6 @@
76
76
  "esbuild": "^0.25.4",
77
77
  "fast-glob": "^3.3.3",
78
78
  "fast-json-stable-stringify": "^2.1.0",
79
- "form-data": "^4.0.4",
80
79
  "gt-remark": "^1.0.1",
81
80
  "json-pointer": "^0.6.2",
82
81
  "jsonpath-plus": "^10.3.0",
@@ -84,6 +83,7 @@
84
83
  "mdast-util-find-and-replace": "^3.0.2",
85
84
  "micromatch": "^4.0.8",
86
85
  "open": "^10.1.1",
86
+ "pino": "^10.1.0",
87
87
  "remark-frontmatter": "^5.0.0",
88
88
  "remark-mdx": "^3.1.0",
89
89
  "remark-parse": "^11.0.0",
@@ -1,30 +0,0 @@
1
- /**
2
- * Centralized spinner management for tracking multiple async operations
3
- */
4
- export declare class SpinnerManager {
5
- private spinners;
6
- /**
7
- * Run an async operation with a spinner
8
- */
9
- run<T>(id: string, message: string, fn: () => Promise<T>): Promise<T>;
10
- /**
11
- * Mark a spinner as successful
12
- */
13
- succeed(id: string, message: string): void;
14
- /**
15
- * Mark a spinner as warning
16
- */
17
- warn(id: string, message: string): void;
18
- /**
19
- * Start a new spinner
20
- */
21
- start(id: string, message: string): void;
22
- /**
23
- * Stop a specific spinner
24
- */
25
- stop(id: string, message?: string): void;
26
- /**
27
- * Stop all running spinners
28
- */
29
- stopAll(): void;
30
- }
@@ -1,73 +0,0 @@
1
- import chalk from 'chalk';
2
- import { createSpinner } from '../console/logging.js';
3
- /**
4
- * Centralized spinner management for tracking multiple async operations
5
- */
6
- export class SpinnerManager {
7
- spinners = new Map();
8
- /**
9
- * Run an async operation with a spinner
10
- */
11
- async run(id, message, fn) {
12
- const spinner = createSpinner('dots');
13
- this.spinners.set(id, spinner);
14
- spinner.start(message);
15
- try {
16
- const result = await fn();
17
- spinner.stop(chalk.green('✓'));
18
- return result;
19
- }
20
- catch (error) {
21
- spinner.stop(chalk.red('✗'));
22
- throw error;
23
- }
24
- finally {
25
- this.spinners.delete(id);
26
- }
27
- }
28
- /**
29
- * Mark a spinner as successful
30
- */
31
- succeed(id, message) {
32
- const spinner = this.spinners.get(id);
33
- if (spinner) {
34
- spinner.stop(chalk.green(message));
35
- this.spinners.delete(id);
36
- }
37
- }
38
- /**
39
- * Mark a spinner as warning
40
- */
41
- warn(id, message) {
42
- const spinner = this.spinners.get(id);
43
- if (spinner) {
44
- spinner.stop(chalk.yellow(message));
45
- this.spinners.delete(id);
46
- }
47
- }
48
- /**
49
- * Start a new spinner
50
- */
51
- start(id, message) {
52
- const spinner = createSpinner('dots');
53
- this.spinners.set(id, spinner);
54
- spinner.start(message);
55
- }
56
- /**
57
- * Stop a specific spinner
58
- */
59
- stop(id, message) {
60
- const spinner = this.spinners.get(id);
61
- if (spinner) {
62
- spinner.stop(message);
63
- this.spinners.delete(id);
64
- }
65
- }
66
- /**
67
- * Stop all running spinners
68
- */
69
- stopAll() {
70
- this.spinners.forEach((s) => s.stop());
71
- this.spinners.clear();
72
- }
73
- }