@tolgee/cli 2.0.0 → 2.0.1
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/cli.js +2 -1
- package/dist/commands/pull.js +3 -3
- package/dist/commands/push.js +1 -1
- package/dist/utils/logger.js +14 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
@@ -141,7 +141,8 @@ async function run() {
|
|
141
141
|
// - The error should be handled in the command but isn't
|
142
142
|
// - Something went wrong with the code
|
143
143
|
error('An unexpected error occurred while running the command.');
|
144
|
-
|
144
|
+
error('Please report this to our issue tracker: https://github.com/tolgee/tolgee-cli/issues');
|
145
|
+
exitWithError(e);
|
145
146
|
}
|
146
147
|
}
|
147
148
|
run();
|
package/dist/commands/pull.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Command, Option } from 'commander';
|
2
2
|
import { unzipBuffer } from '../utils/zip.js';
|
3
3
|
import { prepareDir } from '../utils/prepareDir.js';
|
4
|
-
import { loading, success } from '../utils/logger.js';
|
4
|
+
import { exitWithError, loading, success } from '../utils/logger.js';
|
5
5
|
import { checkPathNotAFile } from '../utils/checkPathNotAFile.js';
|
6
6
|
import { mapExportFormat } from '../utils/mapExportFormat.js';
|
7
7
|
import { handleLoadableError } from '../client/TolgeeClient.js';
|
@@ -26,7 +26,7 @@ async function fetchZipBlob(opts) {
|
|
26
26
|
const pullHandler = () => async function () {
|
27
27
|
const opts = this.optsWithGlobals();
|
28
28
|
if (!opts.path) {
|
29
|
-
|
29
|
+
exitWithError('Missing option --path <path> or `pull.path` in tolgee config');
|
30
30
|
}
|
31
31
|
await checkPathNotAFile(opts.path);
|
32
32
|
const zipBlob = await loading('Fetching strings from Tolgee...', fetchZipBlob(opts));
|
@@ -37,7 +37,7 @@ const pullHandler = () => async function () {
|
|
37
37
|
export default (config) => new Command()
|
38
38
|
.name('pull')
|
39
39
|
.description('Pulls translations from Tolgee')
|
40
|
-
.addOption(new Option('
|
40
|
+
.addOption(new Option('--path <path>', 'Destination of a folder where translation files will be stored in').default(config.pull?.path))
|
41
41
|
.addOption(new Option('-l, --languages <languages...>', 'List of languages to pull. Leave unspecified to export them all').default(config.pull?.languagess))
|
42
42
|
.addOption(new Option('-s, --states <states...>', 'List of translation states to include. Defaults all except untranslated')
|
43
43
|
.choices(['UNTRANSLATED', 'TRANSLATED', 'REVIEWED'])
|
package/dist/commands/push.js
CHANGED
@@ -74,7 +74,7 @@ async function readRecords(matchers) {
|
|
74
74
|
const pushHandler = (config) => async function () {
|
75
75
|
const opts = this.optsWithGlobals();
|
76
76
|
if (!config.push?.files) {
|
77
|
-
|
77
|
+
exitWithError('Missing option `push.files` in configuration file.');
|
78
78
|
}
|
79
79
|
const filteredMatchers = config.push.files.filter((r) => {
|
80
80
|
if (opts.languages && !opts.languages.includes(r.language)) {
|
package/dist/utils/logger.js
CHANGED
@@ -59,10 +59,20 @@ export function warn(msg) {
|
|
59
59
|
export function error(msg) {
|
60
60
|
console.log(`🔴 ${msg}`);
|
61
61
|
}
|
62
|
-
export function exitWithError(
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
export function exitWithError(err) {
|
63
|
+
let message;
|
64
|
+
let stack;
|
65
|
+
if (err instanceof Error) {
|
66
|
+
message = err.message;
|
67
|
+
stack = err.stack;
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
message = err;
|
71
|
+
stack = getStackTrace();
|
72
|
+
}
|
73
|
+
error(message);
|
74
|
+
if (debugEnabled && stack) {
|
75
|
+
console.log(stack);
|
66
76
|
}
|
67
77
|
process.exit(1);
|
68
78
|
}
|