gtx-cli 2.5.4 → 2.5.6
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 +15 -0
- package/dist/api/saveLocalEdits.js +5 -1
- package/dist/cli/base.js +1 -0
- package/dist/console/index.js +1 -1
- package/dist/react/jsx/utils/getPathsAndAliases.d.ts +4 -1
- package/dist/react/jsx/utils/getPathsAndAliases.js +4 -1
- package/dist/react/jsx/utils/jsxParsing/parseJsx.d.ts +1 -1
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js +30 -12
- package/dist/react/parse/createInlineUpdates.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.5.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#817](https://github.com/generaltranslation/gt/pull/817) [`80eef0e`](https://github.com/generaltranslation/gt/commit/80eef0e0f61d5a07ed850aa39b25e81bddd12b34) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: Static component resolution edge cases
|
|
8
|
+
|
|
9
|
+
## 2.5.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#815](https://github.com/generaltranslation/gt/pull/815) [`e7d25b0`](https://github.com/generaltranslation/gt/commit/e7d25b06a3e1d7ca404d64257570b88e7b0d1915) Thanks [@brian-lou](https://github.com/brian-lou)! - Batch enqueue jobs
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`e7d25b0`](https://github.com/generaltranslation/gt/commit/e7d25b06a3e1d7ca404d64257570b88e7b0d1915)]:
|
|
16
|
+
- generaltranslation@8.0.2
|
|
17
|
+
|
|
3
18
|
## 2.5.4
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -2,7 +2,8 @@ import { aggregateFiles } from '../formats/files/translate.js';
|
|
|
2
2
|
import { collectAndSendUserEditDiffs } from './collectUserEditDiffs.js';
|
|
3
3
|
import { gt } from '../utils/gt.js';
|
|
4
4
|
import { BranchStep } from '../workflow/BranchStep.js';
|
|
5
|
-
import { logErrorAndExit } from '../console/logging.js';
|
|
5
|
+
import { createSpinner, logErrorAndExit } from '../console/logging.js';
|
|
6
|
+
import chalk from 'chalk';
|
|
6
7
|
/**
|
|
7
8
|
* Uploads current source files to obtain file references, then collects and sends
|
|
8
9
|
* diffs for all locales based on last downloaded versions. Does not enqueue translations.
|
|
@@ -29,5 +30,8 @@ export async function saveLocalEdits(settings) {
|
|
|
29
30
|
fileId: file.fileId,
|
|
30
31
|
versionId: file.versionId,
|
|
31
32
|
}));
|
|
33
|
+
const spinner = createSpinner('dots');
|
|
34
|
+
spinner.start('Saving local edits...');
|
|
32
35
|
await collectAndSendUserEditDiffs(uploads, settings);
|
|
36
|
+
spinner.stop(chalk.green('Local edits saved successfully'));
|
|
33
37
|
}
|
package/dist/cli/base.js
CHANGED
|
@@ -72,6 +72,7 @@ export class BaseCLI {
|
|
|
72
72
|
.command('save-local')
|
|
73
73
|
.description('Save local edits for all configured files by sending diffs (no translation enqueued)')
|
|
74
74
|
.action(async () => {
|
|
75
|
+
displayHeader('Saving local edits...');
|
|
75
76
|
const config = findFilepath(['gt.config.json']);
|
|
76
77
|
const settings = await generateSettings({ config });
|
|
77
78
|
await saveLocalEdits(settings);
|
package/dist/console/index.js
CHANGED
|
@@ -25,7 +25,7 @@ export const warnDuplicateFunctionDefinitionSync = (file, functionName, location
|
|
|
25
25
|
export const warnInvalidStaticInitSync = (file, functionName, location) => withLocation(file, withStaticError(`The definition for ${colorizeFunctionName(functionName)} could not be resolved. When using arrow syntax to define a static function, the right hand side or the assignment MUST only contain the arrow function itself and no other expressions.
|
|
26
26
|
Example: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = () => { ... }`)}
|
|
27
27
|
Invalid: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = [() => { ... }][0]`)}`), location);
|
|
28
|
-
export const warnRecursiveFunctionCallSync = (file, functionName, location) => withLocation(file, withStaticError(`Recursive function call detected: ${colorizeFunctionName(functionName)}. A static function use recursive calls to construct its result.`), location);
|
|
28
|
+
export const warnRecursiveFunctionCallSync = (file, functionName, location) => withLocation(file, withStaticError(`Recursive function call detected: ${colorizeFunctionName(functionName)}. A static function cannot use recursive calls to construct its result.`), location);
|
|
29
29
|
// Re-export error messages
|
|
30
30
|
export const noLocalesError = `No locales found! Please provide a list of locales to translate to, or specify them in your gt.config.json file.`;
|
|
31
31
|
export const noDefaultLocaleError = `No default locale found! Please provide a default locale, or specify it in your gt.config.json file.`;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { NodePath } from '@babel/traverse';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Constructs tracking for gt related variables of interest
|
|
4
|
+
* inlineTranslationPaths: these are string-related translation functions
|
|
5
|
+
* translationComponentPaths: these are just <T> components
|
|
6
|
+
* importAliases: any other GT related imports
|
|
4
7
|
*/
|
|
5
8
|
export declare function getPathsAndAliases(ast: any, pkg: 'gt-react' | 'gt-next'): {
|
|
6
9
|
importAliases: Record<string, string>;
|
|
@@ -4,7 +4,10 @@ import { extractImportName } from './parseAst.js';
|
|
|
4
4
|
// Handle CommonJS/ESM interop
|
|
5
5
|
const traverse = traverseModule.default || traverseModule;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Constructs tracking for gt related variables of interest
|
|
8
|
+
* inlineTranslationPaths: these are string-related translation functions
|
|
9
|
+
* translationComponentPaths: these are just <T> components
|
|
10
|
+
* importAliases: any other GT related imports
|
|
8
11
|
*/
|
|
9
12
|
export function getPathsAndAliases(ast, pkg) {
|
|
10
13
|
// First pass: collect imports and process translation functions
|
|
@@ -35,7 +35,7 @@ export declare function buildJSXTree({ importAliases, node, unwrappedExpressions
|
|
|
35
35
|
node: any;
|
|
36
36
|
callStack: string[];
|
|
37
37
|
unwrappedExpressions: string[];
|
|
38
|
-
visited: Set<string
|
|
38
|
+
visited: Set<string> | null;
|
|
39
39
|
updates: Updates;
|
|
40
40
|
errors: string[];
|
|
41
41
|
warnings: Set<string>;
|
|
@@ -202,6 +202,9 @@ export function buildJSXTree({ importAliases, node, unwrappedExpressions, visite
|
|
|
202
202
|
});
|
|
203
203
|
if (elementIsVariable) {
|
|
204
204
|
if (componentType === STATIC_COMPONENT) {
|
|
205
|
+
if (visited === null) {
|
|
206
|
+
visited = new Set();
|
|
207
|
+
}
|
|
205
208
|
return resolveStaticComponentChildren({
|
|
206
209
|
importAliases,
|
|
207
210
|
scopeNode,
|
|
@@ -376,7 +379,7 @@ export function parseJSXElement({ importAliases, node, originalName, pkg, update
|
|
|
376
379
|
importAliases,
|
|
377
380
|
node,
|
|
378
381
|
scopeNode,
|
|
379
|
-
visited:
|
|
382
|
+
visited: null,
|
|
380
383
|
callStack: [],
|
|
381
384
|
pkg,
|
|
382
385
|
unwrappedExpressions,
|
|
@@ -486,7 +489,7 @@ function resolveStaticComponentChildren({ importAliases, scopeNode, children, un
|
|
|
486
489
|
: child.expression.callee);
|
|
487
490
|
const calleeBinding = scopeNode.scope.getBinding(callee.name);
|
|
488
491
|
if (!calleeBinding) {
|
|
489
|
-
warnFunctionNotFoundSync(file, callee.name, `${callee.loc?.start?.line}:${callee.loc?.start?.column}`);
|
|
492
|
+
warnings.add(warnFunctionNotFoundSync(file, callee.name, `${callee.loc?.start?.line}:${callee.loc?.start?.column}`));
|
|
490
493
|
continue;
|
|
491
494
|
}
|
|
492
495
|
// Function is found locally, return wrapped in an expression
|
|
@@ -577,17 +580,29 @@ function resolveStaticFunctionInvocationFromBinding({ importAliases, calleeBindi
|
|
|
577
580
|
});
|
|
578
581
|
}
|
|
579
582
|
else if (importedFunctionsMap.has(callee.name)) {
|
|
583
|
+
// Get the original function name
|
|
584
|
+
let originalName;
|
|
585
|
+
if (calleeBinding.path.isImportSpecifier()) {
|
|
586
|
+
originalName = t.isIdentifier(calleeBinding.path.node.imported)
|
|
587
|
+
? calleeBinding.path.node.imported.name
|
|
588
|
+
: calleeBinding.path.node.imported.value;
|
|
589
|
+
}
|
|
590
|
+
else if (calleeBinding.path.isImportDefaultSpecifier()) {
|
|
591
|
+
originalName = calleeBinding.path.node.local.name;
|
|
592
|
+
}
|
|
593
|
+
else if (calleeBinding.path.isImportNamespaceSpecifier()) {
|
|
594
|
+
originalName = calleeBinding.path.node.local.name;
|
|
595
|
+
}
|
|
580
596
|
// Function is being imported
|
|
581
597
|
const importPath = importedFunctionsMap.get(callee.name);
|
|
582
598
|
const filePath = resolveImportPath(file, importPath, parsingOptions, resolveImportPathCache);
|
|
583
|
-
if (filePath) {
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
functionName,
|
|
599
|
+
if (filePath && originalName) {
|
|
600
|
+
const result = withRecusionGuard({
|
|
601
|
+
filename: filePath,
|
|
602
|
+
functionName: originalName,
|
|
588
603
|
cb: () => processFunctionInFile({
|
|
589
604
|
filePath,
|
|
590
|
-
functionName,
|
|
605
|
+
functionName: originalName,
|
|
591
606
|
visited,
|
|
592
607
|
callStack,
|
|
593
608
|
unwrappedExpressions,
|
|
@@ -599,6 +614,9 @@ function resolveStaticFunctionInvocationFromBinding({ importAliases, calleeBindi
|
|
|
599
614
|
pkg,
|
|
600
615
|
}),
|
|
601
616
|
});
|
|
617
|
+
if (result !== null) {
|
|
618
|
+
return result;
|
|
619
|
+
}
|
|
602
620
|
}
|
|
603
621
|
}
|
|
604
622
|
warnings.add(warnFunctionNotFoundSync(file, callee.name, `${callee.loc?.start?.line}:${callee.loc?.start?.column}`));
|
|
@@ -644,7 +662,7 @@ function processFunctionInFile({ filePath, functionName, visited, callStack, par
|
|
|
644
662
|
});
|
|
645
663
|
const reExports = [];
|
|
646
664
|
const warnDuplicateFuncDef = (path) => {
|
|
647
|
-
warnings.add(warnDuplicateFunctionDefinitionSync(
|
|
665
|
+
warnings.add(warnDuplicateFunctionDefinitionSync(filePath, functionName, `${path.node.loc?.start?.line}:${path.node.loc?.start?.column}`));
|
|
648
666
|
};
|
|
649
667
|
traverse(ast, {
|
|
650
668
|
// Handle function declarations: function getInfo() { ... }
|
|
@@ -663,7 +681,7 @@ function processFunctionInFile({ filePath, functionName, visited, callStack, par
|
|
|
663
681
|
updates,
|
|
664
682
|
errors,
|
|
665
683
|
warnings,
|
|
666
|
-
file,
|
|
684
|
+
file: filePath,
|
|
667
685
|
parsingOptions,
|
|
668
686
|
importedFunctionsMap,
|
|
669
687
|
});
|
|
@@ -689,7 +707,7 @@ function processFunctionInFile({ filePath, functionName, visited, callStack, par
|
|
|
689
707
|
warnings,
|
|
690
708
|
visited,
|
|
691
709
|
unwrappedExpressions,
|
|
692
|
-
file,
|
|
710
|
+
file: filePath,
|
|
693
711
|
parsingOptions,
|
|
694
712
|
importedFunctionsMap,
|
|
695
713
|
});
|
|
@@ -735,7 +753,7 @@ function processFunctionInFile({ filePath, functionName, visited, callStack, par
|
|
|
735
753
|
updates,
|
|
736
754
|
errors,
|
|
737
755
|
warnings,
|
|
738
|
-
file,
|
|
756
|
+
file: filePath,
|
|
739
757
|
pkg,
|
|
740
758
|
});
|
|
741
759
|
if (foundResult != null) {
|
|
@@ -35,7 +35,7 @@ export async function createInlineUpdates(pkg, validate, filePatterns, parsingOp
|
|
|
35
35
|
// Parse <T> components
|
|
36
36
|
for (const { localName, path } of translationComponentPaths) {
|
|
37
37
|
parseTranslationComponent({
|
|
38
|
-
importAliases
|
|
38
|
+
importAliases,
|
|
39
39
|
originalName: localName,
|
|
40
40
|
localName,
|
|
41
41
|
ast,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtx-cli",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"unified": "^11.0.5",
|
|
94
94
|
"unist-util-visit": "^5.0.0",
|
|
95
95
|
"yaml": "^2.8.0",
|
|
96
|
-
"generaltranslation": "8.0.
|
|
96
|
+
"generaltranslation": "8.0.2"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@babel/types": "^7.28.4",
|