gtx-cli 1.2.12 → 1.2.14
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/dist/api/sendUpdates.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.sendUpdates = sendUpdates;
|
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const console_1 = require("../console");
|
|
9
9
|
const updateConfig_1 = __importDefault(require("../fs/config/updateConfig"));
|
|
10
|
+
const utils_1 = require("../config/utils");
|
|
10
11
|
/**
|
|
11
12
|
* Sends updates to the API
|
|
12
13
|
* @param updates - The updates to send
|
|
@@ -48,9 +49,16 @@ async function sendUpdates(updates, options, library) {
|
|
|
48
49
|
spinner.stop(chalk_1.default.red(await response.text()));
|
|
49
50
|
process.exit(1);
|
|
50
51
|
}
|
|
51
|
-
const { versionId, message, locales } = await response.json();
|
|
52
|
+
const { versionId, message, locales, projectSettings } = await response.json();
|
|
52
53
|
spinner.stop(chalk_1.default.green('Sent updates'));
|
|
53
54
|
(0, console_1.logSuccess)(message);
|
|
55
|
+
if ((0, utils_1.isUsingLocalTranslations)(options) && projectSettings.cdnEnabled) {
|
|
56
|
+
(0, console_1.logWarning)(chalk_1.default.yellow('Your project is configured to use the CDN, but you are also using local translations. Please disable one or the other.'));
|
|
57
|
+
}
|
|
58
|
+
else if (!(0, utils_1.isUsingLocalTranslations)(options) &&
|
|
59
|
+
!projectSettings.cdnEnabled) {
|
|
60
|
+
(0, console_1.logWarning)(chalk_1.default.yellow('Your project is not using the CDN, nor are you using local translations. Please enable one or the other.'));
|
|
61
|
+
}
|
|
54
62
|
if (options.config) {
|
|
55
63
|
await (0, updateConfig_1.default)({
|
|
56
64
|
configFilepath: options.config,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isUsingLocalTranslations = isUsingLocalTranslations;
|
|
4
|
+
// returns true if the project is configured to use local translations
|
|
5
|
+
function isUsingLocalTranslations(settings) {
|
|
6
|
+
return settings.files && settings.files.placeholderPaths.gt;
|
|
7
|
+
}
|
|
@@ -40,6 +40,9 @@ function addGTIdentifierToSyntaxTree(tree, startingIndex = 0) {
|
|
|
40
40
|
key: (0, getVariableName_1.getVariableName)({ ...props, 'data-_gt': generaltranslation }, 'datetime'),
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
+
else if (type === "" || type === "React.Fragment") {
|
|
44
|
+
generaltranslation.transformation = 'fragment';
|
|
45
|
+
}
|
|
43
46
|
if (type === 'Plural') {
|
|
44
47
|
generaltranslation.transformation = 'plural';
|
|
45
48
|
const pluralBranches = Object.entries(props).reduce((acc, [branchName, branch]) => {
|
|
@@ -151,11 +151,16 @@ function buildJSXTree(importAliases, node, unwrappedExpressions, updates, errors
|
|
|
151
151
|
const children = node.children
|
|
152
152
|
.map((child) => buildJSXTree(importAliases, child, unwrappedExpressions, updates, errors, file))
|
|
153
153
|
.filter((child) => child !== null && child !== '');
|
|
154
|
+
const props = {};
|
|
155
|
+
if (children.length === 1) {
|
|
156
|
+
props.children = children[0];
|
|
157
|
+
}
|
|
158
|
+
else if (children.length > 1) {
|
|
159
|
+
props.children = children;
|
|
160
|
+
}
|
|
154
161
|
return {
|
|
155
162
|
type: '',
|
|
156
|
-
props
|
|
157
|
-
children: children.length === 1 ? children[0] : children,
|
|
158
|
-
},
|
|
163
|
+
props,
|
|
159
164
|
};
|
|
160
165
|
}
|
|
161
166
|
// If it's a string literal (standalone)
|
|
@@ -4,6 +4,7 @@ exports.translate = translate;
|
|
|
4
4
|
const fetchTranslations_1 = require("../api/fetchTranslations");
|
|
5
5
|
const waitForUpdates_1 = require("../api/waitForUpdates");
|
|
6
6
|
const save_1 = require("../formats/gt/save");
|
|
7
|
+
const utils_1 = require("../config/utils");
|
|
7
8
|
async function translate(settings, versionId) {
|
|
8
9
|
// timeout was validated earlier
|
|
9
10
|
const startTime = Date.now();
|
|
@@ -14,7 +15,7 @@ async function translate(settings, versionId) {
|
|
|
14
15
|
}
|
|
15
16
|
const translations = await (0, fetchTranslations_1.fetchTranslations)(settings.baseUrl, settings.apiKey, versionId);
|
|
16
17
|
// Save translations to local directory if files.gt.output is provided
|
|
17
|
-
if (settings.files &&
|
|
18
|
+
if (settings.files && (0, utils_1.isUsingLocalTranslations)(settings)) {
|
|
18
19
|
await (0, save_1.saveTranslations)(translations, settings.files.placeholderPaths, 'JSX');
|
|
19
20
|
}
|
|
20
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtx-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@babel/parser": "^7.25.7",
|
|
66
66
|
"@babel/plugin-transform-react-jsx": "^7.25.9",
|
|
67
67
|
"@babel/traverse": "^7.25.7",
|
|
68
|
-
"@clack/prompts": "^0.
|
|
68
|
+
"@clack/prompts": "^0.11.0",
|
|
69
69
|
"chalk": "^4.1.2",
|
|
70
70
|
"commander": "^12.1.0",
|
|
71
71
|
"dotenv": "^16.4.5",
|