gtx-cli 1.2.11 → 1.2.13
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
|
+
}
|
|
@@ -96,12 +96,12 @@ function buildJSXTree(importAliases, node, unwrappedExpressions, updates, errors
|
|
|
96
96
|
typeName = null;
|
|
97
97
|
}
|
|
98
98
|
// Convert from alias to original name
|
|
99
|
-
const
|
|
99
|
+
const componentType = importAliases[typeName ?? ''];
|
|
100
100
|
// If this JSXElement is one of the recognized variable components,
|
|
101
|
-
const elementIsVariable = VARIABLE_COMPONENTS.includes(
|
|
101
|
+
const elementIsVariable = VARIABLE_COMPONENTS.includes(componentType);
|
|
102
102
|
const props = {};
|
|
103
|
-
const elementIsPlural =
|
|
104
|
-
const elementIsBranch =
|
|
103
|
+
const elementIsPlural = componentType === 'Plural';
|
|
104
|
+
const elementIsBranch = componentType === 'Branch';
|
|
105
105
|
element.openingElement.attributes.forEach((attr) => {
|
|
106
106
|
if (t.isJSXAttribute(attr)) {
|
|
107
107
|
const attrName = attr.name.name;
|
|
@@ -128,7 +128,7 @@ function buildJSXTree(importAliases, node, unwrappedExpressions, updates, errors
|
|
|
128
128
|
if (elementIsVariable) {
|
|
129
129
|
parseJSXElement(importAliases, element, updates, errors, file);
|
|
130
130
|
return {
|
|
131
|
-
type:
|
|
131
|
+
type: componentType,
|
|
132
132
|
props,
|
|
133
133
|
};
|
|
134
134
|
}
|
|
@@ -142,7 +142,7 @@ function buildJSXTree(importAliases, node, unwrappedExpressions, updates, errors
|
|
|
142
142
|
props.children = children;
|
|
143
143
|
}
|
|
144
144
|
return {
|
|
145
|
-
type:
|
|
145
|
+
type: componentType,
|
|
146
146
|
props,
|
|
147
147
|
};
|
|
148
148
|
}
|
|
@@ -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.13",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"localization",
|
|
54
54
|
"cli"
|
|
55
55
|
],
|
|
56
|
-
"author": "",
|
|
56
|
+
"author": "General Translation, Inc.",
|
|
57
57
|
"license": "FSL-1.1-ALv2",
|
|
58
58
|
"bugs": {
|
|
59
59
|
"url": "https://github.com/generaltranslation/gt/issues"
|
|
@@ -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",
|