gtx-cli 2.5.34-alpha.0 → 2.5.35-bin.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 (33) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/binaries/gtx-cli-darwin-arm64 +0 -0
  3. package/binaries/gtx-cli-darwin-x64 +0 -0
  4. package/binaries/gtx-cli-linux-arm64 +0 -0
  5. package/binaries/gtx-cli-linux-x64 +0 -0
  6. package/binaries/gtx-cli-win32-x64.exe +0 -0
  7. package/dist/api/collectUserEditDiffs.js +25 -3
  8. package/dist/bin/bin-main.js +0 -0
  9. package/dist/console/index.d.ts +1 -3
  10. package/dist/console/index.js +1 -5
  11. package/dist/generated/version.d.ts +1 -1
  12. package/dist/generated/version.js +1 -1
  13. package/dist/main.js +0 -0
  14. package/dist/react/jsx/utils/constants.d.ts +1 -3
  15. package/dist/react/jsx/utils/constants.js +3 -13
  16. package/dist/react/jsx/utils/getPathsAndAliases.js +3 -3
  17. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +2 -0
  18. package/dist/react/jsx/utils/jsxParsing/parseJsx.d.ts +4 -6
  19. package/dist/react/jsx/utils/jsxParsing/parseJsx.js +154 -168
  20. package/dist/react/jsx/utils/parseStringFunction.d.ts +0 -10
  21. package/dist/react/jsx/utils/parseStringFunction.js +10 -63
  22. package/dist/workflow/download.js +0 -1
  23. package/package.json +3 -3
  24. package/dist/console/formatting.d.ts +0 -1
  25. package/dist/console/formatting.js +0 -7
  26. package/dist/react/jsx/utils/getCalleeNameFromExpression.d.ts +0 -9
  27. package/dist/react/jsx/utils/getCalleeNameFromExpression.js +0 -32
  28. package/dist/react/jsx/utils/parseDeclareStatic.d.ts +0 -15
  29. package/dist/react/jsx/utils/parseDeclareStatic.js +0 -540
  30. package/dist/react/jsx/utils/parseString.d.ts +0 -25
  31. package/dist/react/jsx/utils/parseString.js +0 -539
  32. package/dist/react/jsx/utils/types.d.ts +0 -14
  33. package/dist/react/jsx/utils/types.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.5.35
4
+
5
+ ### Patch Changes
6
+
7
+ - [#905](https://github.com/generaltranslation/gt/pull/905) [`e73bf82`](https://github.com/generaltranslation/gt/commit/e73bf820422771a59408eb643e22ef7f99682b9f) Thanks [@brian-lou](https://github.com/brian-lou)! - Fix CLI failure handling
8
+
9
+ ## 2.5.34
10
+
11
+ ### Patch Changes
12
+
13
+ - [#904](https://github.com/generaltranslation/gt/pull/904) [`51d412f`](https://github.com/generaltranslation/gt/commit/51d412f503bbb838daaaca47fc8165873ce1857e) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Assign `save-local` changes to most recent download
14
+
3
15
  ## 2.5.33
4
16
 
5
17
  ### Patch Changes
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -7,6 +7,27 @@ import { gt } from '../utils/gt.js';
7
7
  import os from 'node:os';
8
8
  import { randomUUID } from 'node:crypto';
9
9
  import { hashStringSync } from '../utils/hash.js';
10
+ const findLatestDownloadedVersion = (downloadedVersions, branchId, fileId, locale) => {
11
+ const versionsForFile = downloadedVersions.entries?.[branchId]?.[fileId] ?? undefined;
12
+ if (!versionsForFile)
13
+ return null;
14
+ let latest = null;
15
+ for (const [versionId, locales] of Object.entries(versionsForFile)) {
16
+ const entry = locales?.[locale];
17
+ if (!entry)
18
+ continue;
19
+ const updatedAt = entry.updatedAt
20
+ ? Date.parse(entry.updatedAt)
21
+ : Number.NEGATIVE_INFINITY;
22
+ const latestUpdatedAt = latest?.entry.updatedAt
23
+ ? Date.parse(latest.entry.updatedAt)
24
+ : Number.NEGATIVE_INFINITY;
25
+ if (!latest || updatedAt > latestUpdatedAt) {
26
+ latest = { versionId, entry };
27
+ }
28
+ }
29
+ return latest;
30
+ };
10
31
  /**
11
32
  * Collects local user edits by diffing the latest downloaded server translation version
12
33
  * against the current local translation file, and submits the diffs upstream.
@@ -30,9 +51,10 @@ export async function collectAndSendUserEditDiffs(files, settings) {
30
51
  continue;
31
52
  if (!fs.existsSync(outputPath))
32
53
  continue;
33
- const downloadedVersion = downloadedVersions.entries?.[uploadedFile.branchId]?.[uploadedFile.fileId]?.[uploadedFile.versionId]?.[locale];
34
- if (!downloadedVersion)
54
+ const latestDownloaded = findLatestDownloadedVersion(downloadedVersions, uploadedFile.branchId, uploadedFile.fileId, locale);
55
+ if (!latestDownloaded)
35
56
  continue;
57
+ const downloadedVersion = latestDownloaded.entry;
36
58
  // Skip if local file matches the last postprocessed content hash
37
59
  if (downloadedVersion.postProcessHash) {
38
60
  try {
@@ -50,7 +72,7 @@ export async function collectAndSendUserEditDiffs(files, settings) {
50
72
  branchId: uploadedFile.branchId,
51
73
  fileName: uploadedFile.fileName,
52
74
  fileId: uploadedFile.fileId,
53
- versionId: uploadedFile.versionId,
75
+ versionId: latestDownloaded.versionId,
54
76
  locale: locale,
55
77
  outputPath,
56
78
  });
File without changes
@@ -14,13 +14,11 @@ export declare const warnAsyncUseGT: (file: string, location?: string) => string
14
14
  export declare const warnSyncGetGT: (file: string, location?: string) => string;
15
15
  export declare const warnTernarySync: (file: string, location?: string) => string;
16
16
  export declare const withLocation: (file: string, message: string, location?: string) => string;
17
+ export declare const warnInvalidStaticChildSync: (file: string, location?: string) => string;
17
18
  export declare const warnFunctionNotFoundSync: (file: string, functionName: string, location?: string) => string;
18
- export declare const warnInvalidDeclareVarNameSync: (file: string, value: string, location?: string) => string;
19
19
  export declare const warnDuplicateFunctionDefinitionSync: (file: string, functionName: string, location?: string) => string;
20
20
  export declare const warnInvalidStaticInitSync: (file: string, functionName: string, location?: string) => string;
21
21
  export declare const warnRecursiveFunctionCallSync: (file: string, functionName: string, location?: string) => string;
22
- export declare const warnDeclareStaticNotWrappedSync: (file: string, functionName: string, location?: string) => string;
23
- export declare const warnDeclareStaticNoResultsSync: (file: string, functionName: string, location?: string) => string;
24
22
  export declare const noLocalesError = "No locales found! Please provide a list of locales to translate to, or specify them in your gt.config.json file.";
25
23
  export declare const noDefaultLocaleError = "No default locale found! Please provide a default locale, or specify it in your gt.config.json file.";
26
24
  export declare const noFilesError = "Incorrect or missing files configuration! Please make sure your files are configured correctly in your gt.config.json file.";
@@ -1,9 +1,7 @@
1
1
  import { colorizeFilepath, colorizeComponent, colorizeIdString, colorizeContent, colorizeLine, colorizeFunctionName, } from './colors.js';
2
- import { formatCodeClamp } from './formatting.js';
3
2
  const withWillErrorInNextVersion = (message) => `${message} (This will become an error in the next major version of the CLI.)`;
4
3
  // Static function related errors
5
4
  const withStaticError = (message) => `<Static> rules violation: ${message}`;
6
- const withDeclareStaticError = (message) => `declareStatic() rules violation: ${message}`;
7
5
  // Synchronous wrappers for backward compatibility
8
6
  export const warnApiKeyInConfigSync = (optionsFilepath) => `${colorizeFilepath(optionsFilepath)}: Your API key is exposed! Please remove it from the file and include it as an environment variable.`;
9
7
  export const warnVariablePropSync = (file, attrName, value, location) => withLocation(file, `${colorizeComponent('<T>')} component has dynamic attribute ${colorizeIdString(attrName)} with value: ${colorizeContent(value)}. Change ${colorizeIdString(attrName)} to ensure this content is translated.`, location);
@@ -22,15 +20,13 @@ export const warnAsyncUseGT = (file, location) => withLocation(file, `Found useG
22
20
  export const warnSyncGetGT = (file, location) => withLocation(file, `Found getGT() in a synchronous function. Use useGT() instead, or make the function async.`, location);
23
21
  export const warnTernarySync = (file, location) => withLocation(file, 'Found ternary expression. A Branch component may be more appropriate here.', location);
24
22
  export const withLocation = (file, message, location) => `${colorizeFilepath(file)}${location ? ` (${colorizeLine(location)})` : ''}: ${message}`;
23
+ export const warnInvalidStaticChildSync = (file, location) => withLocation(file, 'Found invalid <Static> invocation. Children must be an expression container with a function invocation. Callee must be a single identifier. (Example: <T> <Static> {getSubject()} </Static> </T>)', location);
25
24
  export const warnFunctionNotFoundSync = (file, functionName, location) => withLocation(file, `Function ${colorizeFunctionName(functionName)} definition could not be resolved. This might affect translation resolution for this ${colorizeComponent('<T>')} component.`, location);
26
- export const warnInvalidDeclareVarNameSync = (file, value, location) => withLocation(file, `Found invalid declareVar() $name tag. Must be a static expression. Received: ${colorizeContent(value)}.`, location);
27
25
  export const warnDuplicateFunctionDefinitionSync = (file, functionName, location) => withLocation(file, `Function ${colorizeFunctionName(functionName)} is defined multiple times. Only the first definition will be used.`, location);
28
26
  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.
29
27
  Example: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = () => { ... }`)}
30
28
  Invalid: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = [() => { ... }][0]`)}`), location);
31
29
  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);
32
- export const warnDeclareStaticNotWrappedSync = (file, functionName, location) => withLocation(file, withDeclareStaticError(`Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. This call is not wrapped in declareStatic(). Ensure the function is properly wrapped with declareStatic() and does not have circular import dependencies.`), location);
33
- export const warnDeclareStaticNoResultsSync = (file, functionName, location) => withLocation(file, withDeclareStaticError(`Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. DeclareStatic can only receive function invocations and cannot use undefined values or looped calls to construct its result.`), location);
34
30
  // Re-export error messages
35
31
  export const noLocalesError = `No locales found! Please provide a list of locales to translate to, or specify them in your gt.config.json file.`;
36
32
  export const noDefaultLocaleError = `No default locale found! Please provide a default locale, or specify it in your gt.config.json file.`;
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "2.5.34-alpha.0";
1
+ export declare const PACKAGE_VERSION = "2.5.35-bin.0";
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- export const PACKAGE_VERSION = '2.5.34-alpha.0';
2
+ export const PACKAGE_VERSION = '2.5.35-bin.0';
package/dist/main.js CHANGED
File without changes
@@ -1,6 +1,4 @@
1
- export declare const DECLARE_VAR_FUNCTION = "declareVar";
2
- export declare const DECLARE_STATIC_FUNCTION = "declareStatic";
3
- export declare const MSG_TRANSLATION_FUNCTION = "msg";
1
+ export declare const MSG_TRANSLATION_HOOK = "msg";
4
2
  export declare const INLINE_TRANSLATION_HOOK = "useGT";
5
3
  export declare const INLINE_TRANSLATION_HOOK_ASYNC = "getGT";
6
4
  export declare const INLINE_MESSAGE_HOOK = "useMessages";
@@ -1,6 +1,4 @@
1
- export const DECLARE_VAR_FUNCTION = 'declareVar';
2
- export const DECLARE_STATIC_FUNCTION = 'declareStatic';
3
- export const MSG_TRANSLATION_FUNCTION = 'msg';
1
+ export const MSG_TRANSLATION_HOOK = 'msg';
4
2
  export const INLINE_TRANSLATION_HOOK = 'useGT';
5
3
  export const INLINE_TRANSLATION_HOOK_ASYNC = 'getGT';
6
4
  export const INLINE_MESSAGE_HOOK = 'useMessages';
@@ -13,9 +11,7 @@ export const GT_TRANSLATION_FUNCS = [
13
11
  INLINE_TRANSLATION_HOOK_ASYNC,
14
12
  INLINE_MESSAGE_HOOK,
15
13
  INLINE_MESSAGE_HOOK_ASYNC,
16
- MSG_TRANSLATION_FUNCTION,
17
- DECLARE_VAR_FUNCTION,
18
- DECLARE_STATIC_FUNCTION,
14
+ MSG_TRANSLATION_HOOK,
19
15
  TRANSLATION_COMPONENT,
20
16
  STATIC_COMPONENT,
21
17
  'Var',
@@ -67,17 +63,11 @@ export const GT_LIBRARIES_UPSTREAM = {
67
63
  'gt-react',
68
64
  'gt-next',
69
65
  ],
70
- 'gt-react': [
71
- 'gt-i18n',
72
- '@generaltranslation/react-core',
73
- 'gt-react',
74
- 'gt-react-native', // allow for cross-library compatibility (gt-react/gt-react-native only)
75
- ],
66
+ 'gt-react': ['gt-i18n', '@generaltranslation/react-core', 'gt-react'],
76
67
  'gt-react-native': [
77
68
  'gt-i18n',
78
69
  '@generaltranslation/react-core',
79
70
  'gt-react-native',
80
- 'gt-react', // allow for cross-library compatibility (gt-react/gt-react-native only)
81
71
  ],
82
72
  '@generaltranslation/react-core': [
83
73
  'gt-i18n',
@@ -1,5 +1,5 @@
1
1
  import traverseModule from '@babel/traverse';
2
- import { GT_TRANSLATION_FUNCS, INLINE_TRANSLATION_HOOK, INLINE_TRANSLATION_HOOK_ASYNC, INLINE_MESSAGE_HOOK, INLINE_MESSAGE_HOOK_ASYNC, MSG_TRANSLATION_FUNCTION, TRANSLATION_COMPONENT, } from '../../jsx/utils/constants.js';
2
+ import { GT_TRANSLATION_FUNCS, INLINE_TRANSLATION_HOOK, INLINE_TRANSLATION_HOOK_ASYNC, INLINE_MESSAGE_HOOK, INLINE_MESSAGE_HOOK_ASYNC, MSG_TRANSLATION_HOOK, TRANSLATION_COMPONENT, } from '../../jsx/utils/constants.js';
3
3
  import { extractImportName } from './parseAst.js';
4
4
  // Handle CommonJS/ESM interop
5
5
  const traverse = traverseModule.default || traverseModule;
@@ -23,7 +23,7 @@ export function getPathsAndAliases(ast, pkgs) {
23
23
  name.original === INLINE_TRANSLATION_HOOK_ASYNC ||
24
24
  name.original === INLINE_MESSAGE_HOOK ||
25
25
  name.original === INLINE_MESSAGE_HOOK_ASYNC ||
26
- name.original === MSG_TRANSLATION_FUNCTION) {
26
+ name.original === MSG_TRANSLATION_HOOK) {
27
27
  inlineTranslationPaths.push({
28
28
  localName: name.local,
29
29
  path,
@@ -61,7 +61,7 @@ export function getPathsAndAliases(ast, pkgs) {
61
61
  name.original === INLINE_TRANSLATION_HOOK_ASYNC ||
62
62
  name.original === INLINE_MESSAGE_HOOK ||
63
63
  name.original === INLINE_MESSAGE_HOOK_ASYNC ||
64
- name.original === MSG_TRANSLATION_FUNCTION) {
64
+ name.original === MSG_TRANSLATION_HOOK) {
65
65
  inlineTranslationPaths.push({
66
66
  localName: name.local,
67
67
  path: parentPath,
@@ -120,6 +120,8 @@ export function handleChildrenWhitespace(currentTree, parentNodeType = undefined
120
120
  newChildren.push(newElement);
121
121
  break;
122
122
  case 'multiplication':
123
+ // I dont think this case is possible, at least in the array case
124
+ // Can only be child of element or multiplication nodes
123
125
  newChildren.push({
124
126
  nodeType: 'multiplication',
125
127
  branches: handleChildrenWhitespace(child.branches, 'multiplication'),
@@ -3,7 +3,7 @@ import * as t from '@babel/types';
3
3
  import { NodePath } from '@babel/traverse';
4
4
  import { ParsingConfigOptions } from '../../../../types/parsing.js';
5
5
  import traverseModule from '@babel/traverse';
6
- import { MultiplicationNode, JsxTree } from './types.js';
6
+ import { JsxTree } from './types.js';
7
7
  import { GTLibrary } from '../constants.js';
8
8
  /**
9
9
  * Entry point for JSX parsing
@@ -31,11 +31,12 @@ export declare function parseTranslationComponent({ originalName, importAliases,
31
31
  * @param insideT - Whether the current node is inside a <T> component
32
32
  * @returns The built JSX tree
33
33
  */
34
- export declare function buildJSXTree({ importAliases, node, unwrappedExpressions, inStatic, visited, callStack, updates, errors, warnings, file, insideT, parsingOptions, scopeNode, importedFunctionsMap, pkgs, helperPath, }: {
34
+ export declare function buildJSXTree({ importAliases, node, unwrappedExpressions, visited, callStack, updates, errors, warnings, file, insideT, parsingOptions, scopeNode, importedFunctionsMap, pkgs, }: {
35
35
  importAliases: Record<string, string>;
36
36
  node: any;
37
37
  callStack: string[];
38
38
  unwrappedExpressions: string[];
39
+ visited: Set<string> | null;
39
40
  updates: Updates;
40
41
  errors: string[];
41
42
  warnings: Set<string>;
@@ -45,10 +46,7 @@ export declare function buildJSXTree({ importAliases, node, unwrappedExpressions
45
46
  scopeNode: NodePath;
46
47
  importedFunctionsMap: Map<string, string>;
47
48
  pkgs: GTLibrary[];
48
- inStatic: boolean;
49
- visited: Set<string> | null;
50
- helperPath: NodePath;
51
- }): JsxTree | MultiplicationNode;
49
+ }): JsxTree;
52
50
  export declare function parseJSXElement({ importAliases, node, originalName, pkgs, updates, errors, warnings, file, parsingOptions, scopeNode, importedFunctionsMap, }: {
53
51
  importAliases: Record<string, string>;
54
52
  node: t.JSXElement;