@tolgee/cli 1.3.1 → 1.4.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/arguments.js +2 -0
- package/dist/client/export.js +0 -4
- package/dist/client/import.js +0 -2
- package/dist/client/internal/requester.js +2 -2
- package/dist/commands/extract/check.js +4 -3
- package/dist/commands/extract/print.js +4 -3
- package/dist/commands/sync/compare.js +4 -3
- package/dist/commands/sync/sync.js +4 -3
- package/dist/extractor/runner.js +2 -2
- package/package.json +1 -1
package/dist/client/export.js
CHANGED
@@ -8,8 +8,6 @@ export default class ExportClient {
|
|
8
8
|
method: 'POST',
|
9
9
|
path: `${this.requester.projectUrl}/export`,
|
10
10
|
body: { ...req, zip: true },
|
11
|
-
headersTimeout: 300,
|
12
|
-
bodyTimeout: 300,
|
13
11
|
});
|
14
12
|
}
|
15
13
|
async exportSingle(req) {
|
@@ -17,8 +15,6 @@ export default class ExportClient {
|
|
17
15
|
method: 'POST',
|
18
16
|
path: `${this.requester.projectUrl}/export`,
|
19
17
|
body: { ...req, zip: false },
|
20
|
-
headersTimeout: 300,
|
21
|
-
bodyTimeout: 300,
|
22
18
|
});
|
23
19
|
}
|
24
20
|
}
|
package/dist/client/import.js
CHANGED
@@ -59,8 +59,8 @@ export default class Requester {
|
|
59
59
|
method: req.method,
|
60
60
|
headers: headers,
|
61
61
|
body: body,
|
62
|
-
headersTimeout: req.headersTimeout,
|
63
|
-
bodyTimeout: req.bodyTimeout,
|
62
|
+
headersTimeout: req.headersTimeout ?? 300000,
|
63
|
+
bodyTimeout: req.bodyTimeout ?? 300000,
|
64
64
|
});
|
65
65
|
debug(`[HTTP] ${req.method} ${url} -> ${response.statusCode} ${STATUS_CODES[response.statusCode]}`);
|
66
66
|
if (response.statusCode >= 400)
|
@@ -3,9 +3,10 @@ import { Command } from 'commander';
|
|
3
3
|
import { extractKeysOfFiles } from '../../extractor/runner.js';
|
4
4
|
import { WarningMessages, emitGitHubWarning, } from '../../extractor/warnings.js';
|
5
5
|
import { loading } from '../../utils/logger.js';
|
6
|
-
|
6
|
+
import { FILE_PATTERNS } from '../../arguments.js';
|
7
|
+
async function lintHandler(filesPatterns) {
|
7
8
|
const opts = this.optsWithGlobals();
|
8
|
-
const extracted = await loading('Analyzing code...', extractKeysOfFiles(
|
9
|
+
const extracted = await loading('Analyzing code...', extractKeysOfFiles(filesPatterns, opts.extractor));
|
9
10
|
let warningCount = 0;
|
10
11
|
let filesCount = 0;
|
11
12
|
for (const [file, { warnings }] of extracted) {
|
@@ -35,5 +36,5 @@ async function lintHandler(filesPattern) {
|
|
35
36
|
}
|
36
37
|
export default new Command('check')
|
37
38
|
.description('Checks if the keys can be extracted automatically, and reports problems if any')
|
38
|
-
.
|
39
|
+
.addArgument(FILE_PATTERNS)
|
39
40
|
.action(lintHandler);
|
@@ -3,9 +3,10 @@ import { Command } from 'commander';
|
|
3
3
|
import { extractKeysOfFiles } from '../../extractor/runner.js';
|
4
4
|
import { WarningMessages } from '../../extractor/warnings.js';
|
5
5
|
import { loading } from '../../utils/logger.js';
|
6
|
-
|
6
|
+
import { FILE_PATTERNS } from '../../arguments.js';
|
7
|
+
async function printHandler(filesPatterns) {
|
7
8
|
const opts = this.optsWithGlobals();
|
8
|
-
const extracted = await loading('Analyzing code...', extractKeysOfFiles(
|
9
|
+
const extracted = await loading('Analyzing code...', extractKeysOfFiles(filesPatterns, opts.extractor));
|
9
10
|
let warningCount = 0;
|
10
11
|
const keySet = new Set();
|
11
12
|
for (const [file, { keys, warnings }] of extracted) {
|
@@ -45,5 +46,5 @@ async function printHandler(filesPattern) {
|
|
45
46
|
}
|
46
47
|
export default new Command('print')
|
47
48
|
.description('Prints extracted data to the console')
|
48
|
-
.
|
49
|
+
.addArgument(FILE_PATTERNS)
|
49
50
|
.action(printHandler);
|
@@ -5,9 +5,10 @@ import { extractKeysOfFiles, filterExtractionResult, } from '../../extractor/run
|
|
5
5
|
import { dumpWarnings } from '../../extractor/warnings.js';
|
6
6
|
import { EXTRACTOR } from '../../options.js';
|
7
7
|
import { loading } from '../../utils/logger.js';
|
8
|
-
|
8
|
+
import { FILE_PATTERNS } from '../../arguments.js';
|
9
|
+
async function compareHandler(filesPatterns) {
|
9
10
|
const opts = this.optsWithGlobals();
|
10
|
-
const rawKeys = await loading('Analyzing code...', extractKeysOfFiles(
|
11
|
+
const rawKeys = await loading('Analyzing code...', extractKeysOfFiles(filesPatterns, opts.extractor));
|
11
12
|
dumpWarnings(rawKeys);
|
12
13
|
const localKeys = filterExtractionResult(rawKeys);
|
13
14
|
const remoteKeys = await opts.client.project.fetchAllKeys();
|
@@ -40,6 +41,6 @@ async function compareHandler(pattern) {
|
|
40
41
|
export default new Command()
|
41
42
|
.name('compare')
|
42
43
|
.description('Compares the keys in your code project and in the Tolgee project.')
|
43
|
-
.
|
44
|
+
.addArgument(FILE_PATTERNS)
|
44
45
|
.addOption(EXTRACTOR)
|
45
46
|
.action(compareHandler);
|
@@ -8,6 +8,7 @@ import { unzipBuffer } from '../../utils/zip.js';
|
|
8
8
|
import { askBoolean } from '../../utils/ask.js';
|
9
9
|
import { loading, error } from '../../utils/logger.js';
|
10
10
|
import { EXTRACTOR } from '../../options.js';
|
11
|
+
import { FILE_PATTERNS } from '../../arguments.js';
|
11
12
|
async function backup(client, dest) {
|
12
13
|
const blob = await client.export.export({
|
13
14
|
format: 'JSON',
|
@@ -30,9 +31,9 @@ async function askForConfirmation(keys, operation) {
|
|
30
31
|
process.exit(1);
|
31
32
|
}
|
32
33
|
}
|
33
|
-
async function syncHandler(
|
34
|
+
async function syncHandler(filesPatterns) {
|
34
35
|
const opts = this.optsWithGlobals();
|
35
|
-
const rawKeys = await loading('Analyzing code...', extractKeysOfFiles(
|
36
|
+
const rawKeys = await loading('Analyzing code...', extractKeysOfFiles(filesPatterns, opts.extractor));
|
36
37
|
const warnCount = dumpWarnings(rawKeys);
|
37
38
|
if (!opts.continueOnWarning && warnCount) {
|
38
39
|
console.log(ansi.bold.red('Aborting as warnings have been emitted.'));
|
@@ -96,7 +97,7 @@ async function syncHandler(pattern) {
|
|
96
97
|
export default new Command()
|
97
98
|
.name('sync')
|
98
99
|
.description('Synchronizes the keys in your code project and in the Tolgee project, by creating missing keys and optionally deleting unused ones. For a dry-run, use `tolgee compare`.')
|
99
|
-
.
|
100
|
+
.addArgument(FILE_PATTERNS)
|
100
101
|
.addOption(EXTRACTOR)
|
101
102
|
.option('-B, --backup <path>', 'Path where a backup should be downloaded before performing the sync. If something goes wrong, the backup can be used to restore the project to its previous state.')
|
102
103
|
.option('--continue-on-warning', 'Set this flag to continue the sync if warnings are detected during string extraction. By default, as warnings may indicate an invalid extraction, the CLI will abort the sync.')
|
package/dist/extractor/runner.js
CHANGED
@@ -7,8 +7,8 @@ export async function extractKeysFromFile(file, extractor) {
|
|
7
7
|
file: file,
|
8
8
|
});
|
9
9
|
}
|
10
|
-
export async function extractKeysOfFiles(
|
11
|
-
const files = await glob(
|
10
|
+
export async function extractKeysOfFiles(filesPatterns, extractor) {
|
11
|
+
const files = await glob(filesPatterns, { nodir: true });
|
12
12
|
const result = new Map();
|
13
13
|
await Promise.all(files.map(async (file) => {
|
14
14
|
const keys = await extractKeysFromFile(file, extractor);
|