@tolgee/cli 2.8.4 → 2.9.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.
- package/dist/commands/push.js +17 -1
- package/dist/options.js +1 -0
- package/dist/utils/mapExportFormat.js +2 -0
- package/package.json +1 -1
- package/schema.json +6 -2
package/dist/commands/push.js
CHANGED
@@ -2,6 +2,7 @@ import { extname, join } from 'path';
|
|
2
2
|
import { readdir, readFile, stat } from 'fs/promises';
|
3
3
|
import { Command, Option } from 'commander';
|
4
4
|
import { glob } from 'tinyglobby';
|
5
|
+
import { exit } from 'process';
|
5
6
|
import { loading, success, error, warn, exitWithError, } from '../utils/logger.js';
|
6
7
|
import { askString } from '../utils/ask.js';
|
7
8
|
import { mapImportFormat } from '../utils/mapImportFormat.js';
|
@@ -71,13 +72,24 @@ async function readRecords(matchers) {
|
|
71
72
|
}
|
72
73
|
return result;
|
73
74
|
}
|
75
|
+
function handleMappingError(fileMappings) {
|
76
|
+
error('Not able to map files to existing languages in the platform');
|
77
|
+
console.log(`Pushed files:`);
|
78
|
+
fileMappings.forEach(({ fileName, languageTag }) => {
|
79
|
+
console.log(`"${fileName}"${languageTag ? ` => "${languageTag}"` : ''}`);
|
80
|
+
});
|
81
|
+
console.log('\nYou can use `push.files[*].language` property in `tolgeerc` file to map language correctly');
|
82
|
+
exit(1);
|
83
|
+
}
|
74
84
|
const pushHandler = (config) => async function () {
|
75
85
|
const opts = this.optsWithGlobals();
|
76
86
|
if (!config.push?.files) {
|
77
87
|
exitWithError('Missing option `push.files` in configuration file.');
|
78
88
|
}
|
79
89
|
const filteredMatchers = config.push.files.filter((r) => {
|
80
|
-
if (
|
90
|
+
if (r.language &&
|
91
|
+
opts.languages &&
|
92
|
+
!opts.languages.includes(r.language)) {
|
81
93
|
return false;
|
82
94
|
}
|
83
95
|
if (opts.namespaces && !opts.namespaces.includes(r.namespace ?? '')) {
|
@@ -103,6 +115,7 @@ const pushHandler = (config) => async function () {
|
|
103
115
|
format: format,
|
104
116
|
languageTag: f.language,
|
105
117
|
namespace: f.namespace ?? '',
|
118
|
+
languageTagsToImport: opts.languages,
|
106
119
|
};
|
107
120
|
}),
|
108
121
|
removeOtherKeys: opts.removeOtherKeys,
|
@@ -112,6 +125,9 @@ const pushHandler = (config) => async function () {
|
|
112
125
|
params,
|
113
126
|
}));
|
114
127
|
if (attempt1.error) {
|
128
|
+
if (attempt1.error.code === 'existing_language_not_selected') {
|
129
|
+
handleMappingError(params.fileMappings);
|
130
|
+
}
|
115
131
|
if (attempt1.error.code !== 'conflict_is_not_resolved') {
|
116
132
|
handleLoadableError(attempt1);
|
117
133
|
}
|
package/dist/options.js
CHANGED
@@ -9,6 +9,8 @@ export const mapExportFormat = (format) => {
|
|
9
9
|
};
|
10
10
|
case 'APPLE_XLIFF':
|
11
11
|
return { format: 'APPLE_XLIFF', messageFormat: 'APPLE_SPRINTF' };
|
12
|
+
case 'APPLE_XCSTRINGS':
|
13
|
+
return { format: 'APPLE_XCSTRINGS', messageFormat: 'APPLE_SPRINTF' };
|
12
14
|
case 'COMPOSE_XML':
|
13
15
|
return { format: 'COMPOSE_XML', messageFormat: 'JAVA_STRING_FORMAT' };
|
14
16
|
case 'FLUTTER_ARB':
|
package/package.json
CHANGED
package/schema.json
CHANGED
@@ -219,10 +219,13 @@
|
|
219
219
|
"type": "object",
|
220
220
|
"properties": {
|
221
221
|
"path": { "$ref": "#/$defs/path" },
|
222
|
-
"language": {
|
222
|
+
"language": {
|
223
|
+
"description": "Explicitly map file to language.\n\nIf not provided, backend will try to detect language from language name or it's content.",
|
224
|
+
"type": "string"
|
225
|
+
},
|
223
226
|
"namespace": { "type": "string" }
|
224
227
|
},
|
225
|
-
"required": ["path"
|
228
|
+
"required": ["path"]
|
226
229
|
},
|
227
230
|
"forceMode": {
|
228
231
|
"description": "Specifies how to solve potential conflicts in the pushed data.\n\nOptions:\n\n `OVERRIDE` - update everything according to local files\n `KEEP` - create only non-existent strings, don't touch existing ones\n `NO_FORCE` - throw an error, if there are any conflict",
|
@@ -251,6 +254,7 @@
|
|
251
254
|
"PO_PYTHON",
|
252
255
|
"APPLE_STRINGS",
|
253
256
|
"APPLE_XLIFF",
|
257
|
+
"APPLE_XCSTRINGS",
|
254
258
|
"PROPERTIES_ICU",
|
255
259
|
"PROPERTIES_JAVA",
|
256
260
|
"ANDROID_XML",
|