gtx-cli 2.5.7 → 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 (65) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/api/downloadFileBatch.js +5 -5
  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.js +19 -18
  24. package/dist/formats/json/parseJson.js +14 -13
  25. package/dist/formats/json/utils.js +16 -15
  26. package/dist/formats/yaml/mergeYaml.js +6 -5
  27. package/dist/formats/yaml/parseYaml.js +4 -3
  28. package/dist/formats/yaml/utils.js +4 -3
  29. package/dist/fs/clearLocaleDirs.js +6 -6
  30. package/dist/fs/config/downloadedVersions.js +3 -3
  31. package/dist/fs/config/parseFilesConfig.js +2 -2
  32. package/dist/fs/config/setupConfig.js +2 -2
  33. package/dist/fs/config/updateConfig.js +2 -2
  34. package/dist/fs/config/updateVersions.js +3 -3
  35. package/dist/fs/copyFile.js +2 -2
  36. package/dist/fs/createLoadTranslationsFile.js +3 -3
  37. package/dist/fs/determineFramework.js +3 -3
  38. package/dist/fs/findFilepath.js +5 -4
  39. package/dist/hooks/postProcess.js +9 -9
  40. package/dist/next/parse/handleInitGT.js +2 -2
  41. package/dist/react/parse/addVitePlugin/index.js +4 -3
  42. package/dist/react/parse/addVitePlugin/installCompiler.js +2 -2
  43. package/dist/react/parse/addVitePlugin/updateViteConfig.js +9 -12
  44. package/dist/react/parse/createDictionaryUpdates.js +4 -3
  45. package/dist/react/parse/createInlineUpdates.js +2 -2
  46. package/dist/setup/wizard.js +17 -16
  47. package/dist/translation/parse.js +4 -3
  48. package/dist/translation/stage.js +4 -4
  49. package/dist/translation/validate.js +6 -6
  50. package/dist/utils/addExplicitAnchorIds.js +2 -2
  51. package/dist/utils/credentials.js +4 -3
  52. package/dist/utils/installPackage.js +11 -11
  53. package/dist/utils/packageJson.js +4 -3
  54. package/dist/workflow/BranchStep.js +5 -4
  55. package/dist/workflow/DownloadStep.js +5 -5
  56. package/dist/workflow/EnqueueStep.js +2 -2
  57. package/dist/workflow/PollJobsStep.js +3 -3
  58. package/dist/workflow/SetupStep.js +2 -2
  59. package/dist/workflow/UploadStep.js +3 -3
  60. package/dist/workflow/UserEditDiffsStep.js +2 -2
  61. package/dist/workflow/download.js +4 -3
  62. package/dist/workflow/stage.js +5 -4
  63. package/package.json +2 -2
  64. package/dist/utils/SpinnerManager.d.ts +0 -30
  65. package/dist/utils/SpinnerManager.js +0 -73
@@ -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.7",
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
- }