gtx-cli 2.5.0-alpha.0 → 2.5.0-alpha.2

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 (93) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/collectUserEditDiffs.d.ts +2 -7
  3. package/dist/api/collectUserEditDiffs.js +33 -78
  4. package/dist/api/downloadFileBatch.d.ts +11 -10
  5. package/dist/api/downloadFileBatch.js +120 -127
  6. package/dist/api/saveLocalEdits.js +18 -15
  7. package/dist/cli/base.js +1 -1
  8. package/dist/cli/commands/stage.d.ts +8 -2
  9. package/dist/cli/commands/stage.js +25 -7
  10. package/dist/cli/commands/translate.d.ts +4 -2
  11. package/dist/cli/commands/translate.js +5 -6
  12. package/dist/cli/flags.js +4 -1
  13. package/dist/config/generateSettings.js +10 -0
  14. package/dist/console/colors.d.ts +0 -1
  15. package/dist/console/colors.js +0 -3
  16. package/dist/console/index.d.ts +0 -6
  17. package/dist/console/index.js +2 -13
  18. package/dist/console/logging.d.ts +1 -1
  19. package/dist/console/logging.js +3 -4
  20. package/dist/formats/files/translate.d.ts +2 -2
  21. package/dist/formats/files/translate.js +31 -5
  22. package/dist/fs/config/downloadedVersions.d.ts +10 -3
  23. package/dist/fs/config/downloadedVersions.js +8 -0
  24. package/dist/fs/config/updateVersions.d.ts +2 -1
  25. package/dist/git/branches.d.ts +7 -0
  26. package/dist/git/branches.js +88 -0
  27. package/dist/react/{jsx/utils/jsxParsing → data-_gt}/addGTIdentifierToSyntaxTree.d.ts +1 -2
  28. package/dist/react/{jsx/utils/jsxParsing → data-_gt}/addGTIdentifierToSyntaxTree.js +6 -30
  29. package/dist/react/jsx/evaluateJsx.d.ts +6 -5
  30. package/dist/react/jsx/evaluateJsx.js +4 -32
  31. package/dist/react/jsx/trimJsxStringChildren.d.ts +7 -0
  32. package/dist/react/jsx/trimJsxStringChildren.js +122 -0
  33. package/dist/react/jsx/utils/constants.d.ts +0 -2
  34. package/dist/react/jsx/utils/constants.js +2 -11
  35. package/dist/react/jsx/utils/parseJsx.d.ts +21 -0
  36. package/dist/react/jsx/utils/parseJsx.js +259 -0
  37. package/dist/react/jsx/utils/parseStringFunction.js +141 -4
  38. package/dist/react/parse/createInlineUpdates.js +70 -19
  39. package/dist/types/branch.d.ts +14 -0
  40. package/dist/types/branch.js +1 -0
  41. package/dist/types/data.d.ts +1 -1
  42. package/dist/types/files.d.ts +7 -0
  43. package/dist/types/index.d.ts +7 -0
  44. package/dist/utils/SpinnerManager.d.ts +30 -0
  45. package/dist/utils/SpinnerManager.js +73 -0
  46. package/dist/utils/gitDiff.js +18 -16
  47. package/dist/workflow/BranchStep.d.ts +13 -0
  48. package/dist/workflow/BranchStep.js +131 -0
  49. package/dist/workflow/DownloadStep.d.ts +19 -0
  50. package/dist/workflow/DownloadStep.js +127 -0
  51. package/dist/workflow/EnqueueStep.d.ts +15 -0
  52. package/dist/workflow/EnqueueStep.js +33 -0
  53. package/dist/workflow/PollJobsStep.d.ts +31 -0
  54. package/dist/workflow/PollJobsStep.js +286 -0
  55. package/dist/workflow/SetupStep.d.ts +16 -0
  56. package/dist/workflow/SetupStep.js +72 -0
  57. package/dist/workflow/UploadStep.d.ts +21 -0
  58. package/dist/workflow/UploadStep.js +72 -0
  59. package/dist/workflow/UserEditDiffsStep.d.ts +11 -0
  60. package/dist/workflow/UserEditDiffsStep.js +30 -0
  61. package/dist/workflow/Workflow.d.ts +4 -0
  62. package/dist/workflow/Workflow.js +2 -0
  63. package/dist/workflow/download.d.ts +22 -0
  64. package/dist/workflow/download.js +104 -0
  65. package/dist/workflow/stage.d.ts +14 -0
  66. package/dist/workflow/stage.js +76 -0
  67. package/package.json +3 -4
  68. package/dist/api/checkFileTranslations.d.ts +0 -23
  69. package/dist/api/checkFileTranslations.js +0 -281
  70. package/dist/api/sendFiles.d.ts +0 -17
  71. package/dist/api/sendFiles.js +0 -127
  72. package/dist/api/sendUserEdits.d.ts +0 -19
  73. package/dist/api/sendUserEdits.js +0 -15
  74. package/dist/cli/commands/edits.d.ts +0 -8
  75. package/dist/cli/commands/edits.js +0 -32
  76. package/dist/react/jsx/utils/buildImportMap.d.ts +0 -9
  77. package/dist/react/jsx/utils/buildImportMap.js +0 -30
  78. package/dist/react/jsx/utils/getPathsAndAliases.d.ts +0 -17
  79. package/dist/react/jsx/utils/getPathsAndAliases.js +0 -89
  80. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.d.ts +0 -6
  81. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +0 -199
  82. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.d.ts +0 -13
  83. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +0 -42
  84. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.d.ts +0 -5
  85. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +0 -69
  86. package/dist/react/jsx/utils/jsxParsing/parseJsx.d.ts +0 -60
  87. package/dist/react/jsx/utils/jsxParsing/parseJsx.js +0 -949
  88. package/dist/react/jsx/utils/jsxParsing/parseTProps.d.ts +0 -8
  89. package/dist/react/jsx/utils/jsxParsing/parseTProps.js +0 -47
  90. package/dist/react/jsx/utils/jsxParsing/types.d.ts +0 -48
  91. package/dist/react/jsx/utils/jsxParsing/types.js +0 -34
  92. package/dist/react/jsx/utils/resolveImportPath.d.ts +0 -11
  93. package/dist/react/jsx/utils/resolveImportPath.js +0 -111
@@ -1,8 +0,0 @@
1
- import { Metadata } from 'generaltranslation/types';
2
- import * as t from '@babel/types';
3
- export declare function parseTProps({ openingElement, metadata, componentErrors, file, }: {
4
- openingElement: t.JSXOpeningElement;
5
- metadata: Metadata;
6
- componentErrors: string[];
7
- file: string;
8
- }): void;
@@ -1,47 +0,0 @@
1
- import * as t from '@babel/types';
2
- import generateModule from '@babel/generator';
3
- // Handle CommonJS/ESM interop
4
- const generate = generateModule.default || generateModule;
5
- import { GT_ATTRIBUTES, mapAttributeName } from '../constants.js';
6
- import { isStaticExpression } from '../../evaluateJsx.js';
7
- import { warnVariablePropSync } from '../../../../console/index.js';
8
- // Parse the props of a <T> component
9
- export function parseTProps({ openingElement, metadata, componentErrors, file, }) {
10
- openingElement.attributes.forEach((attr) => {
11
- if (!t.isJSXAttribute(attr))
12
- return;
13
- const attrName = attr.name.name;
14
- if (typeof attrName !== 'string')
15
- return;
16
- if (attr.value) {
17
- // If it's a plain string literal like id="hello"
18
- if (t.isStringLiteral(attr.value)) {
19
- metadata[attrName] = attr.value.value;
20
- }
21
- // If it's an expression container like id={"hello"}, id={someVar}, etc.
22
- else if (t.isJSXExpressionContainer(attr.value)) {
23
- const expr = attr.value.expression;
24
- const code = generate(expr).code;
25
- // Only check for static expressions on id and context props
26
- if (GT_ATTRIBUTES.includes(attrName)) {
27
- const staticAnalysis = isStaticExpression(expr);
28
- if (!staticAnalysis.isStatic) {
29
- componentErrors.push(warnVariablePropSync(file, attrName, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
30
- }
31
- // Use the static value if available
32
- if (staticAnalysis.isStatic && staticAnalysis.value !== undefined) {
33
- metadata[mapAttributeName(attrName)] = staticAnalysis.value;
34
- }
35
- else {
36
- // Only store the code if we couldn't extract a static value
37
- metadata[attrName] = code;
38
- }
39
- }
40
- else {
41
- // For other attributes that aren't id or context
42
- metadata[attrName] = code;
43
- }
44
- }
45
- }
46
- });
47
- }
@@ -1,48 +0,0 @@
1
- type MultiplicationNode = {
2
- nodeType: 'multiplication';
3
- branches: (JsxTree | MultiplicationNode)[];
4
- };
5
- type ExpressionNode = {
6
- nodeType: 'expression';
7
- result: string | number | boolean | MultiplicationNode | null;
8
- };
9
- type ElementNode = {
10
- nodeType: 'element';
11
- type: string;
12
- props?: {
13
- children?: JsxTree | MultiplicationNode | (JsxTree | MultiplicationNode)[];
14
- [key: string]: any;
15
- };
16
- };
17
- type JsxTree = ElementNode | ExpressionNode | string | number | boolean | null;
18
- export type { MultiplicationNode, ExpressionNode, ElementNode, JsxTree };
19
- declare function isElementNode(node: JsxTree | MultiplicationNode): node is ElementNode;
20
- declare function isExpressionNode(node: JsxTree | MultiplicationNode): node is ExpressionNode;
21
- declare function isMultiplicationNode(node: JsxTree | MultiplicationNode): node is MultiplicationNode;
22
- export { isElementNode, isExpressionNode, isMultiplicationNode };
23
- type WhitespaceMultiplicationNode = {
24
- nodeType: 'multiplication';
25
- branches: (WhitespaceJsxTreeResult | WhitespaceMultiplicationNode)[];
26
- };
27
- type WhitespaceJsxTree = {
28
- nodeType?: 'element';
29
- type: string;
30
- props?: {
31
- children?: (WhitespaceJsxTreeResult | WhitespaceMultiplicationNode)[];
32
- [key: string]: any;
33
- };
34
- };
35
- type WhitespaceJsxTreeResult = WhitespaceJsxTree | string | number | boolean | null;
36
- export type { WhitespaceMultiplicationNode, WhitespaceJsxTree, WhitespaceJsxTreeResult, };
37
- declare function isWhitespaceJsxTree(node: WhitespaceJsxTreeResult | WhitespaceMultiplicationNode): node is WhitespaceJsxTree;
38
- declare function isWhitespaceMultiplicationNode(node: WhitespaceJsxTreeResult | WhitespaceMultiplicationNode): node is WhitespaceMultiplicationNode;
39
- export { isWhitespaceJsxTree, isWhitespaceMultiplicationNode };
40
- type MultipliedTree = {
41
- nodeType?: 'element';
42
- type: string;
43
- props?: {
44
- children?: MultipliedTreeNode;
45
- };
46
- };
47
- type MultipliedTreeNode = MultipliedTree | string | number | boolean | null;
48
- export type { MultipliedTree, MultipliedTreeNode };
@@ -1,34 +0,0 @@
1
- // ----- Helpers ----- //
2
- function isElementNode(node) {
3
- return (typeof node === 'object' &&
4
- node !== null &&
5
- 'nodeType' in node &&
6
- node.nodeType === 'element');
7
- }
8
- function isExpressionNode(node) {
9
- return (typeof node === 'object' &&
10
- node !== null &&
11
- 'nodeType' in node &&
12
- node.nodeType === 'expression');
13
- }
14
- function isMultiplicationNode(node) {
15
- return (typeof node === 'object' &&
16
- node !== null &&
17
- 'nodeType' in node &&
18
- node.nodeType === 'multiplication');
19
- }
20
- export { isElementNode, isExpressionNode, isMultiplicationNode };
21
- // ----- Helpers ----- //
22
- function isWhitespaceJsxTree(node) {
23
- return (typeof node === 'object' &&
24
- node !== null &&
25
- 'nodeType' in node &&
26
- node.nodeType === 'element');
27
- }
28
- function isWhitespaceMultiplicationNode(node) {
29
- return (typeof node === 'object' &&
30
- node !== null &&
31
- 'nodeType' in node &&
32
- node.nodeType === 'multiplication');
33
- }
34
- export { isWhitespaceJsxTree, isWhitespaceMultiplicationNode };
@@ -1,11 +0,0 @@
1
- import { ParsingConfigOptions } from '../../../types/parsing.js';
2
- /**
3
- * Resolves import paths to absolute file paths using battle-tested libraries.
4
- * Handles relative paths, TypeScript paths, and node module resolution.
5
- *
6
- * Examples:
7
- * - './constants' -> '/full/path/to/constants.ts'
8
- * - '@/components/ui/button' -> '/full/path/to/src/components/ui/button.tsx'
9
- * - '@shared/utils' -> '/full/path/to/packages/utils/index.ts'
10
- */
11
- export declare function resolveImportPath(currentFile: string, importPath: string, parsingOptions: ParsingConfigOptions, resolveImportPathCache: Map<string, string | null>): string | null;
@@ -1,111 +0,0 @@
1
- import { createMatchPath, loadConfig } from 'tsconfig-paths';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import resolve from 'resolve';
5
- import enhancedResolve from 'enhanced-resolve';
6
- const { ResolverFactory } = enhancedResolve;
7
- /**
8
- * Resolves import paths to absolute file paths using battle-tested libraries.
9
- * Handles relative paths, TypeScript paths, and node module resolution.
10
- *
11
- * Examples:
12
- * - './constants' -> '/full/path/to/constants.ts'
13
- * - '@/components/ui/button' -> '/full/path/to/src/components/ui/button.tsx'
14
- * - '@shared/utils' -> '/full/path/to/packages/utils/index.ts'
15
- */
16
- export function resolveImportPath(currentFile, importPath, parsingOptions, resolveImportPathCache) {
17
- // Check cache first
18
- const cacheKey = `${currentFile}::${importPath}`;
19
- if (resolveImportPathCache.has(cacheKey)) {
20
- return resolveImportPathCache.get(cacheKey);
21
- }
22
- const basedir = path.dirname(currentFile);
23
- const extensions = ['.tsx', '.ts', '.jsx', '.js'];
24
- const mainFields = ['module', 'main'];
25
- let result = null;
26
- // 1. Try tsconfig-paths resolution first (handles TypeScript path mapping)
27
- const tsConfigResult = loadConfig(basedir);
28
- if (tsConfigResult.resultType === 'success') {
29
- const matchPath = createMatchPath(tsConfigResult.absoluteBaseUrl, tsConfigResult.paths, mainFields);
30
- // First try without any extension
31
- let tsResolved = matchPath(importPath);
32
- if (tsResolved && fs.existsSync(tsResolved)) {
33
- result = tsResolved;
34
- resolveImportPathCache.set(cacheKey, result);
35
- return result;
36
- }
37
- // Then try with each extension
38
- for (const ext of extensions) {
39
- tsResolved = matchPath(importPath + ext);
40
- if (tsResolved && fs.existsSync(tsResolved)) {
41
- result = tsResolved;
42
- resolveImportPathCache.set(cacheKey, result);
43
- return result;
44
- }
45
- // Also try the resolved path with extension
46
- tsResolved = matchPath(importPath);
47
- if (tsResolved) {
48
- const resolvedWithExt = tsResolved + ext;
49
- if (fs.existsSync(resolvedWithExt)) {
50
- result = resolvedWithExt;
51
- resolveImportPathCache.set(cacheKey, result);
52
- return result;
53
- }
54
- }
55
- }
56
- }
57
- // 2. Try enhanced-resolve (handles package.json exports field and modern resolution)
58
- try {
59
- const resolver = ResolverFactory.createResolver({
60
- useSyncFileSystemCalls: true,
61
- fileSystem: fs,
62
- extensions,
63
- // Include 'development' condition to resolve to source files in monorepos
64
- conditionNames: parsingOptions.conditionNames, // defaults to ['browser', 'module', 'import', 'require', 'default']. See generateSettings.ts for more details
65
- exportsFields: ['exports'],
66
- mainFields,
67
- });
68
- const resolved = resolver.resolveSync({}, basedir, importPath);
69
- if (resolved) {
70
- result = resolved;
71
- resolveImportPathCache.set(cacheKey, result);
72
- return result;
73
- }
74
- }
75
- catch {
76
- // Fall through to next resolution strategy
77
- }
78
- // 3. Fallback to Node.js resolution (handles relative paths and node_modules)
79
- try {
80
- result = resolve.sync(importPath, { basedir, extensions });
81
- resolveImportPathCache.set(cacheKey, result);
82
- return result;
83
- }
84
- catch {
85
- // If resolution fails, try to manually replace .js/.jsx with .ts/.tsx for source files
86
- if (importPath.endsWith('.js')) {
87
- const tsPath = importPath.replace(/\.js$/, '.ts');
88
- try {
89
- result = resolve.sync(tsPath, { basedir, extensions });
90
- resolveImportPathCache.set(cacheKey, result);
91
- return result;
92
- }
93
- catch {
94
- // Continue to return null
95
- }
96
- }
97
- else if (importPath.endsWith('.jsx')) {
98
- const tsxPath = importPath.replace(/\.jsx$/, '.tsx');
99
- try {
100
- result = resolve.sync(tsxPath, { basedir, extensions });
101
- resolveImportPathCache.set(cacheKey, result);
102
- return result;
103
- }
104
- catch {
105
- // Continue to return null
106
- }
107
- }
108
- resolveImportPathCache.set(cacheKey, null);
109
- return null;
110
- }
111
- }